B4J Library [B4x] B4xDialog4Button

I needed a dialog with 4 options and rather than rewrite the b4xDialog class I opted for a different approach.

This class adds a panel to an existing B4xDialog and adds 4 Buttons. quite simple really.




Some code was borrowed from the B4xDialog B4xLib so I could ensure compatibility across platforms.

I attach a b4xlib and the source code in a b4j project.

Depends On:
  • XUI
  • XUI Views
Usage:

B4X:
    Dialog.Title = "Add type"
    Dialog.ButtonsFont = xui.CreateDefaultFont(14)

    Dim D4 As B4xDialog4Button
    D4.Initialize(Dialog)
    Wait For (D4.Show("Select","NewBtn","Positive","Negative","Cancel")) Complete (Resp As Int)

    Select Resp
        Case D4.DialogResponse_NewButton
            Log("NewButton")
        Case D4.DialogResponse_Cancel
            Log("Cancel")
        Case D4.DialogResponse_Negative
            Log("Negative")
        Case D4.DialogResponse_Positive
            Log("Positive")
       
    End Select

Update to v1.1
  • Added ShowCustom and ShowTemplate
  • Buttons will not respond to State changes (B4xInputTemplate) but works if you need the 4th button.

I can't test it on B4i, but there is no reason it shouldn't work.

Let me know how you get on with it.
 

Attachments

  • B4xDialog4Button1.1.zip
    3.6 KB · Views: 318
  • B4xDialog4Button.b4xlib
    1.5 KB · Views: 342
Last edited:

stevel05

Expert
Licensed User
Longtime User
Tip: If you try to display a dialog on the same dialog object immediately after this one, it fails (on B4j at least). I can't yet work out why, but will keep looking.
for now add a Sleep(100) before the next dialog and it will work.
 

stevel05

Expert
Licensed User
Longtime User
Update to v1.1
  • Added ShowCustom and ShowTemplate
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…