B4J Question GUI Updating Problems

Colin Harvey

Member
Licensed User
Hi, there seems to be a fundamental problem with B4J/A, in that the GUI cant reliably update its appearance while work is inprogress.

eg, I want to have a Button that when clicked:
- disables itself & grays its text colour (to give the user a visual sign that work is under way)
- does some work (several seconds elapsed)
- resets its text colour to black & re-enables itself

Unfortunately this doesnt work as the GUI doesnt update while the program is busy !
This seems like a significant omission compared to Visual Basic which the B4 apps are a substitute for.
I see many similar discussions about DoEvents, Progress Bars, and other problems updating the GUI while work is in-progress.
Is there anything that can be done to resolve this fundamental problem !? (eg. a command to force updates / Refresh the GUI)

One of the joys of VB was the ability to update the GUI while the app was running without having to code complicated workarounds like Timers, or support threads !
 

stevel05

Expert
Licensed User
Longtime User
Can you show the code you've tried. It sounds like the structure is not correct.
 
Upvote 0

Colin Harvey

Member
Licensed User
sleep is problematic for other reasons though, ie. it turns the procedure into a Resumable sub which complicates the sequencing of procedures
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
eg, I want to have a Button that when clicked:
- disables itself & grays its text colour (to give the user a visual sign that work is under way)
- does some work (several seconds elapsed)
- resets its text colour to black & re-enables itself
This should be simple to do with resumable subs. You need to provide more information about the second step. Maybe post some code.

DoEvents was never a good solution and had all kinds of bad and uncontrollable side effects. Modern UI frameworks do not allow the layout to be updated synchronously.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…