Android Question DDD.CreateToolbar - recognize Label Properties

Mark Stuart

Well-Known Member
Licensed User
Longtime User
I've noticed on other Android apps that the bottom Toolbar/Navigation "buttons" when touched show the button with round ends - the left and right ends.
Even animation to the button when pressed.
So any chance when setting the Label Properties / Color and Corner Radius, that they be recognized when the "button" is pressed?

I read in Erel's comments introducing the DDD, that the Text Properties are only recognized.
It would be nice to have these other properties be used.

Thanx,
Mark Stuart
 
Create a class and put this code:
Code: Copy
Private Sub CreateToolbar (DesignerArgs As DesignerArgs)
    Dim pnl As B4XView = DesignerArgs.GetViewFromArgs(0)
    If DesignerArgs.FirstRun Then
        Dim StubLabel As B4XView = pnl.GetView(0)
        StubLabel.RemoveViewFromParent
        Dim EventName As String = DesignerArgs.Arguments.Get(1)
        Dim fnt As B4XFont = StubLabel.Font
        For i = 2 To DesignerArgs.Arguments.Size - 1 Step 2
            Dim text As String = DesignerArgs.Arguments.Get(i)
            Dim tag As String = DesignerArgs.Arguments.Get(i + 1)
            Dim lbl As B4XView = CreateLabel
            lbl.Font = fnt
            lbl.Text = text
            lbl.TextColor = StubLabel.TextColor
            lbl.SetTextAlignment("CENTER", "CENTER")
            lbl.Tag = Array(DesignerArgs.LayoutModule, EventName, tag)
            pnl.AddView(lbl, 0, 0, 40dip, pnl.Height)
        Next
    Else
        For i = 0 To pnl.NumberOfViews - 1
            pnl.GetView(i).Height = pnl.Height
        Next
    End If
End Sub

Private Sub CreateLabel As B4XView
    Dim lbl As Label
    lbl.Initialize("lbl")
    Return lbl
End Sub

#if B4J
Private Sub lbl_MouseClicked (EventData As MouseEvent)
    RaiseToolbarEvent(Sender, Sender.As(B4XView).Tag)
    EventData.Consume
End Sub
#else
Private Sub lbl_Click
    RaiseToolbarEvent(Sender, Sender.As(B4XView).Tag)
End Sub
#End If

Private Sub RaiseToolbarEvent (lbl As B4XView, Data() As Object)
    CallSubDelayed2(Data(0), Data(1) & "_click", Data(2))
    If ToolbarPressedColor <> 0 Then
        lbl.SetColorAnimated(100, xui.Color_Transparent, ToolbarPressedColor)
        Sleep(100)
        lbl.SetColorAnimated(100, ToolbarPressedColor, xui.Color_Transparent)
    End If
End Sub
You can now modify it as you need.
 
Upvote 0
I copied that script into a new B4A Standard Class named DDD. All sorts of issues in it.
I don't know what I'm doing. Where do I start?

Maybe you can help.

Thanx,
Mark Stuart
 
Upvote 0
Example.
One of the options is to unpack the DesignerUtils.b4xlib library and add or modify the functionality.
1657645680381.png
 

Attachments

Upvote 0
another option is to create your own functionality,

See an example.
 
Upvote 0
Another one is to wait for Erel to do it ?
this reminds me of a similar situation, an image of a @LucaMs roulette. ???

but now @Erel recommend.
A new internal library is available named DesignerUtils. It includes a class named DDD with all kinds of useful method. I recommend developers to check it source code (inside the b4xlib = zip).
 
Upvote 0
Renamed the Class module but the logger is complaining with the following handler.
Something about it needs to be in an Activity.
B4X: Copy
Private Sub CreateLabel As B4XView
    Dim lbl As Label
    lbl.Initialize("lbl")
    Return lbl
End Sub
 
Upvote 0
Back
Top