B4A Class [B4X] XUI - haB4XMsgBox (based on B4XDialog)

Discussion in 'Additional libraries, classes and official updates' started by Harris, Jan 16, 2019.

  1. Harris

    Harris Well-Known Member Licensed User

    Based on @Erel latest B4Xlibs projects, I created this modified class from the B4XDialog source class.
    With posted (expertly developed) classes, we can create anything that suits our purpose - without struggling to "get it right". Thanks @Erel - for the lesson on correctness.

    The modifications include:
    Remove dependency on B4XBitmapCreator (no blur support)
    Larger overall box (width adjusted - based on portrait, landscape, tablet, phone)
    Larger text font size
    Large Buttons with border and background
    Buttons stretch to fit box width (with 1, 2, 3 buttons)
    Button text is sized accordingly (number of buttons, text.length)
    Button color based on return code
    Supports up to 4 return codes ( -1 Positive, -2 Negative, -3 Cancel, 0 Abort [Back Button on TitleBar] )
    Supports FontAwesome for Title, body and buttons
    No Designer Script required (as per original source)

    Should work on all three platforms since B4X XUI conditionals remain.
    I created it for my needs in B4A and B4i. I use ABMaterial for my B4J needs...

    Customize as you wish!

    Enjoy. Thanks
    (I love classes - and wine glasses...)

    Typical Use:

    ' Activity Globals
    Private Dialog As haB4XMsgBox
    Private Base As B4XView

    ' Activity_Create(FirstTime As Boolean)
        Base = Activity
        Dialog.Initialize (Base)

    ' device (each activity) Back KeyPress handling... Keeps app foreground
    Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event

    If KeyCode = KeyCodes.KEYCODE_BACK And Dialog.Visible Then
    ' ( or return 0 - Abort )
            Return True
    End If
    Return False
    End Sub

    ' button click call...

    Dim msgContent As String = "This is your first chance to opt in for free stuff."&CRLF&CRLF&"( no "&Chr(0xF1F0)&" or "&Chr(0xF1F1)&" required )"&CRLF&CRLF&"Please select your intention."
    '        Wait For (Dialog.Show(Chr(0xF0E7)&" Get FREE Stuff!",msgContent,Chr(0xF046),  "","") ) Complete (Result As Int)
    '        Wait For (Dialog.Show("Get FREE Stuff "&Chr(0xF0E7),msgContent, Chr(0xF046),  "NO THANKS","") ) Complete (Result As Int)
    '        Wait For (Dialog.Show(Chr(0xF0E7)&" Get FREE Stuff!",msgContent,"OK", "","NEVER") ) Complete (Result As Int)
             Wait For (Dialog.Show(Chr(0xF0E7)&" Get FREE Stuff!",msgContent,Chr(0xF046), "PERHAPS LATER""NO THANKS") ) Complete (Result As Int)

    Log(" Chosen Result: "&Result)


    Capture+_2019-01-15-12-02-22 (Medium).png

    Capture+_2019-01-15-12-01-44 (Medium).png


    Screenshot_20190115-131048 (Medium).jpg

    Screenshot_20190115-131120 (Medium).jpg

    Attached Files:

    Last edited: Jan 16, 2019
  2. Erel

    Erel Administrator Staff Member Licensed User

    This is also supported by the standard B4XDialog in B4A as it accepts CSBuilder objects for the buttons and title. I will add it to B4i as well.
    Harris likes this.
  3. Harris

    Harris Well-Known Member Licensed User

    Last edited: Jan 16, 2019
  4. Erel

    Erel Administrator Staff Member Licensed User

    You should post questions in the questions forum...
    Harris likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice