Bug? fx msgbox(2)

HansDieter

Member
Licensed User
Longtime User
In https://www.b4x.com/b4j/help/jfx.html#jfx_msgbox_confirmation the example

example:
If fx.Msgbox2(MainForm, "Do you want to save changes?", "Example", "Yes", "Cancel", "No", _
  fx.MSGBOX_CONFIRMATION) = fx.DialogResponse.POSITIVE Then
  Log("saving file...")
End If

The log says "Types do not match. (warning #22)"

It doesn't compile.



Error:
B4J Version: 9.10
Parsing code.    (0.07s)
    Java Version: 11
Building folders structure.    (0.08s)
Compiling code.    (0.13s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    Error
B4J line: 108
If fx.Msgbox2(Main, \
src\VHD\Spritlader\liste.java:199: error: incompatible types: Class<CAP#1> cannot be converted to Form
if (_fx.Msgbox2((anywheresoftware.b4j.objects.Form)(_main.getObject()),"Do you want to save changes?","Example","Yes","Cancel","No",_fx.MSGBOX_CONFIRMATION)==_fx.DialogResponse.POSITIVE) {
                                                   ^
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object from capture of ?
1 error
 

agraham

Expert
Licensed User
Longtime User
It works for me. Have you set MainForm correctly?

B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private Button1 As B4XView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
End Sub

Sub Button1_Click

    If fx.Msgbox2(MainForm, "Do you want to save changes?", "Example", "Yes", "Cancel", "No", _
  fx.MSGBOX_CONFIRMATION) = fx.DialogResponse.POSITIVE Then
        Log("saving file...")
    End If
End Sub
 

HansDieter

Member
Licensed User
Longtime User
Have you set MainForm correctly?
That was it. I did setup the MainForm correctly but the MSGBOX is an other modul with an and form. With the corret form it compiles.
Thank you
 
Top