B4J Question [Solved]How to change fx.MSGBOX_WARNING in Msgbox2Async()

Olaan

Expert
Licensed User
Longtime User
Code:
Private Sub Button2_Click
    'old
'    Dim res As Int = fx.Msgbox2(MainForm, "Do you want to save changes?", "Save Data", "Yes", "Cancel", "No", fx.MSGBOX_WARNING)
'    If res = fx.DialogResponse.POSITIVE Then
'        Log("Saving changes...")
'    End If
'-------------------------------------------------------------------------------------
     'new
   
    Dim res As Object=  xui.Msgbox2Async("Do you want to save changes?","Save Data","Yes","Cancel","No", fx.MSGBOX_WARNING )
    Wait For (res) Msgbox_Result (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Log("Saving changes...")
    End If
      
End Sub
 
Solution
screencap.png

I don't see the issue... besides the fact that there was a double declaration for the same variable in the code. One as Int one as Object.
Just use your own image file and load it.

B4X:
Dim res As Object=  xui.Msgbox2Async("Do you want to save changes?","Save Data","Yes","Cancel","No", fx.LoadImage(File.DirAssets,"yourfile.png"))

You could have any number of images for any case you may need.
 
Upvote 0
Just use your own image file and load it.

B4X:
Dim res As Object=  xui.Msgbox2Async("Do you want to save changes?","Save Data","Yes","Cancel","No", fx.LoadImage(File.DirAssets,"yourfile.png"))

You could have any number of images for any case you may need.
Thank you for your reply.
 
Upvote 0
Is possibility using fx.MSGBOX_WARNING directly?
 
Upvote 0
I don't think it is possible since these values are matched to the JavaFX static final constants. By definition they can not be modified. Check the JavaFX documentation on AlertType.
After I have tested your strategy ,it doesn't work.
Code:
Dim res As Object=  xui.Msgbox2Async("Do you want to save changes?","Save Data","Yes","Cancel","No", fx.LoadImage(File.DirAssets,"yourfile.png"))
 

Attachments

Upvote 0
This works:
B4X:
Dim res As Object=  xui.Msgbox2Async("Do you want to save changes?","Save Data","Yes","Cancel","No", xui.LoadBitmap(File.DirAssets,"yourfile.png"))
You must have an image file in the Files folder of the project. Replace "yourfile.png" by the name of the image file you want to use.
 
Upvote 0
Back
Top