Modal dialog

  1. 2 weeks ago

    Hi everyone. There is an unclear situation that I can see while trying to show "Modal dialog". Message box is showing before openning the modal dialog. So after I click "Ok" in message box, modal dialog shows but not before. And another thing after I uncomment "m.Close" section, modal dialog doesn't show at all, only message box.
    Thanks in advance.

    Xojo 2019R1
    WebPage->Shown event handler:

    Dim m As new Modal1
    m.show
    MsgBox("hi")
    //m.Close

    On the web, Modal doesn’t mean that it blocks code execution... only that it prevents the user from interacting with other parts of your app.

    Additionally, when your xojo code runs on the app, the portion which affects the browser (like msgbox and m.show) gets converted to JavaScript commands, sent to the browser and run as a contiguous stream of commands, so when followed by m.close, your dialog probably never appears even for a millisecond because the browser optimizes away the two css style changes (one to make it appear and one to hide it).

  2. Paul L

    May 7 Xojo Inc http://docs.xojo.com

    These things are not synchronous on web like they are on desktop. More information here:

    https://docs.xojo.com/UserGuide:Web_Dialog_Boxes

  3. Michel B

    May 7 Pre-Release Testers RubberViews.com

    Both a modal dialog and Msgbox are modal. Fighting modals are no good.

  4. Greg O

    May 8 Xojo Inc Answer

    On the web, Modal doesn’t mean that it blocks code execution... only that it prevents the user from interacting with other parts of your app.

    Additionally, when your xojo code runs on the app, the portion which affects the browser (like msgbox and m.show) gets converted to JavaScript commands, sent to the browser and run as a contiguous stream of commands, so when followed by m.close, your dialog probably never appears even for a millisecond because the browser optimizes away the two css style changes (one to make it appear and one to hide it).

  5. Edited 2 weeks ago

    @Greg OLone On the web, Modal doesn’t mean that it blocks code execution... only that it prevents the user from interacting with other parts of your app.

    Additionally, when your xojo code runs on the app, the portion which affects the browser (like msgbox and m.show) gets converted to JavaScript commands, sent to the browser and run as a contiguous stream of commands, so when followed by m.close, your dialog probably never appears even for a millisecond because the browser optimizes away the two css style changes (one to make it appear and one to hide it).

    Now it's more clear.
    But I can also describe a similar situation with a modal (web) dialog.

    In the beginning of "Shown" event I call "Show" event of a modal dialog, for example "m.show". Then I make a query using Database.SQLSelect and get some values.
    After it I close the modal dialog "m.close".

    The point is that the modal dialog is shown after the query to a DB is done but not before. So you can see the modal dialog for less than a second.
    Is this because of the browser optimization described above? Because I was waiting from the application to show the webdialog in the beginning and closing after all previous lines of code is executed.
    Thanks all for answers.

  6. Michel B

    May 8 Pre-Release Testers RubberViews.com
    Edited 2 weeks ago

    In Web, changes in the UI happen only when an event or method is finished.

    So, you cannot do all you describe in the Shown event, since any change such as showing a modal dialog will only happen when the shown event closes.

    Use WebTimers to sequence execution.

    For instance, use a 200 ms or so WebTimer you start in shown to show your WebDialog and start your SQL query, then use another 200 ms WebTimer you start from the first WebTimer Action event to close the modal dialog.

or Sign Up to reply!