Hi everyone,
I’m building a Xojo Web app and I want to change the cursor to WebStyle.Cursors.Wait
while a task runs.
I don’t want to use Timer.CallLater
or lose the session context.
But when I do this: (in the pressed event of a button)
Self.Style.Cursor = WebStyle.Cursors.Wait
// do a slow task
Self.Style.Cursor = WebStyle.Cursors.Default
the “Wait” cursor never shows.
I understand the browser doesn’t repaint until the method ends, but is there any way to force the cursor change earlier?
Thanks for any ideas!
The Web (and Desktop) frameworks won’t send anything to the browser (or UI) until the end of the stack. You must break up the change in cursor from the long-running-function. The best way to do this is with a Thread. The more-of-a-mess method is to use a Timer.
Using the Web Framework versions of those should retain the Session context.
WebThread
WebTimer
Keep in mind that Web Apps are not the same design paradigm as Desktop Apps. It is possible that a Web App user may not have a cursor (i.e. mobile / touch). Using a more obvious pacifier like a WebProgressWheel would be my recommended approach.
3 Likes
Thanks so much! Using a WebThread
with a WebProgressWheel
worked perfectly.Really appreciate your help!
2 Likes