Modal dialog

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

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

https://documentation.xojo.com/topics/user_interface/web/dialog_boxes.html

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

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).

[quote=435466:@Greg O’Lone]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).[/quote]

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.

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.