is there anyway to show a modal as a "Please Wait" when a page is starting to be SHOWN?

Hi Guys,

I have an existing program (very large) which I would like to have a “Please wait” modal appear when certain pages are shown.

I have tried everything I can think of.

if you put modal1.show in the SHOWN even it wont show, not sure why.
If you put modal1.show in the OPEN event then it wont show as the webpage isn’t shown yet.

It doesn’t work if you call it from the previous window or button on the previous page.
I have tried timers etc…

I like the modal due to it locking the user from “clicking randomly” and the way it appears on the screen.

Once I am in the page I am fine and can use the modal1.show from the mouseDOWN and mouseUP events

Any ideas

thanks
damon

Show the modal in Session Open. The default web page will display underneath.

Fwiw, the reason you are having trouble is that the framework queues up commands and sends them all at once. So if you show a dialog and do a bunch of other stuff and then close the dialog, the end result is that the dialog never shows.

You can solve some of this by showing a dialog and then starting a WebThread from which you push changes out to the page and then hide the dialog when that process completes.

Hi Michel,
Tried that and it doesn’t work.
Well that isn’t exactly true, since the page itself isn’t shown the modal cannot be seen.
It is actually being shown but it isn’t visible.
I know this because if you put a button on the web page and try to SHOW the modal then nothing shows.
If you have another button to hide the modal and press it first and then the show button then the modal will show.

I would expect this to be an “undocumented feature”

Thanks
Damon

Hi Greg,

Yes - I understand why it happens.
Was hoping there would be some “super smart” way of doing it easily.
Having to make 100+ threads for 100+ shown events of the pages will take a while.

Thanks
Damon

HI Michel,
re-read your reply.
Not sure if that will work or not however I need it to work when you move from one page to another.
Thanks
damon

Hi All,

this is the easiest I can make it.

CUT everything in the SHOWN event of your window to a new Method called showNOW
Give showNOW the parameter “sender as thread”

In the SHOWN event put

WebDialog11.Show (or whatever you have called the modal)

dim WaitThread as new WebThread
AddHandler WaitThread.Run , AddressOf showNOW
WaitThread.Run

In the showNOW event you process everything to load up that window and at the end of it you have
WebDialog11.hide

If anyone can simplify this please send help.

thanks
Damon

Hi Damon,
your method it’s exactly what Greg suggested you.

[quote=259953:@damon pillinger]Hi Michel,
Tried that and it doesn’t work.
Well that isn’t exactly true, since the page itself isn’t shown the modal cannot be seen.
It is actually being shown but it isn’t visible.
I know this because if you put a button on the web page and try to SHOW the modal then nothing shows.
If you have another button to hide the modal and press it first and then the show button then the modal will show.

I would expect this to be an “undocumented feature”
[/quote]

You do not understand. I tested before suggesting. For all intents and purposes, the modal IS a web page. It can be displayed at any time BEFORE a web page. But because it is modal, it always displays on top. So when you show a web page, it goes behind.

In session :

Sub Open() dim m as new modal1 m.show End Sub

If you want to display a new page with the dialog on top, do in a button :

Sub Action() dim m as new modal1 m.show webpage2.show End Sub

brillliant.

just to pad it out a bit

in the session create a property called WaitDialog of type Webdialog1
create your webdialog with anything you need and call it Webdialog1

In the session.open event put
WaitDialog = new WebDialog1
WaitDialog .show

In the button ACTION event put
Session.WaitDialog .show
webpage2.show

In the SHOWN event of webpage2 put
Session.WaitDialog .hide

Works a charm.
Any thing else???

any ideas for a popupmenu?

thanks
damon

Hi Maurizio,

I know that is why I posted it so others might find it - if they ever needed it.
Thanks
Damon

Hi Michel,

If I use a combination of yours a Greg for a popupmenu.selectionchanged it works very well

Session.WaitDialog .show
dim WaitThread as new WebThread
AddHandler WaitThread.Run , AddressOf selectionchanged
WaitThread.Run

In the method “SelectionChanged” it ends with session.waitdialog.hide

Is there anything better?

many thanks
Damon

works great for a TEXTFIELD.LOSTFOCUS as well

Many thanks again
Damon

there isn’t anyway to do this?

dim WaitThread as new WebThread
AddHandler WaitThread.Run , AddressOf "

dim i as integer
dim s,q as string
dim tt as Double = ticks
for i= 1 to 5000
s=s+“fdsifufbsdfvuds”
q=NthField( s, “fd”,i)
next

Session.waitdialog.hide
"

WaitThread.Run

Basically, without having to copy it into an extra method

Thanks
damon

What do you want to achieve ? A delay ?

[quote=260060:@damon pillinger]there isn’t anyway to do this?

dim WaitThread as new WebThread
AddHandler WaitThread.Run , AddressOf "

dim i as integer
dim s,q as string
dim tt as Double = ticks
for i= 1 to 5000
s=s+“fdsifufbsdfvuds”
q=NthField( s, “fd”,i)
next

Session.waitdialog.hide
"

WaitThread.Run

Basically, without having to copy it into an extra method

Thanks
damon[/quote]
No. You must use a method. We don’t do inlines in Xojo.

Hi Greg,

thanks - thought so.

Damon

I have a modal that has a helper method that shows a spinner while doing processing. I then have a helper to call it with any method:

DoProcesses(AddressOf ReloadQuery)

The helper method is in a Global Module:

Sub DoProcesses(ParamArray Processes() as WDProcessing.BlankDelegate) Session.Pause = true dim wd as new WDProcessing wd.Processes = Processes wd.Show End Sub

The WebDialog called “WDProcessing” looks like this:

https://xojo.io/3d649415b4f4

The important part is having the blank delegate created, a Processes array property to store the delegates, and a method to run them.

for i as integer = 0 to Processes.Ubound Processes(i).invoke next Close