B4J Question Refresh UI while running step by step (F8)

LucaMs

Expert
Licensed User
Longtime User
Question from a newbie who has been using B4J for many years, but I have not found an answer.
When you run the step-by-step project, pressing F8, the graphic instructions are not applied immediately, the form is not updated.
Is there a way to do it?
 

teddybear

Well-Known Member
Licensed User
I don't quite understand, but I can step in it to refresh UI with a basic UI project.

1.png
2.png
3.png
4.png
5.png
6.png
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I don't quite understand, but I can step in it to refresh UI with a basic UI project.
First: as you can see, the dialog is empty until "End Sub" is executed.
Also, that is a special case, just because it is a MsgBoxAsync.

Try so:
B4X:
Sub Button1_Click
    xui.MsgboxAsync("Hello World!", "B4X")

    Button1.Left = 200
    Log("LucaMs is really stupid; it is evident from the questions he posts.")
End Sub
 
Last edited:
Upvote 0

EnriqueGonzalez

Expert
Licensed User
Longtime User
B4j UI threads are always updated last and they are not even ordered FiFo.

They will be enqueued and once all other processes finish then UI thread will be updated on no particular order.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
B4j UI threads are always updated last and they are not even ordered FiFo.

They will be enqueued and once all other processes finish then UI thread will be updated on no particular order.
Thank you for the information, but what I was asking is if there is a solution, because in this way the debugging of the graphics is difficult, at most you can use log commands.

Maybe a MyForm.Refresh, implemented by Erel?

Only now I also noticed that bug, the button that returns to its original position.

I have not used VB Net for a long time (too heavy for my ancient PC) and I do not remember if it also has this problem.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
There is also a bug: the button returns to its original position!
I don't think it is a bug. if you don't handle resize event, it will stay at the original position.
7.png
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
In this way:
B4X:
Sub Button1_Click
 Log("stop")
 xui.MsgboxAsync("Hello World!", "B4X")

 Button1.Left = 200
 Sleep(300)
 Log("LucaMs is really stupid; it is evident from the questions he posts.")
End Sub
by putting breakpoints on the Log lines, executing the instruction with the msgbox by pressing F8 and then F5, at the next break the button actually goes to x 200 (but you struggle to find the form on the Desktop).
The fact remains that then the button returns to its initial position.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
The fact remains that then the button returns to its initial position.
As I said, the handle resize event of the MainForm is checked as default in Visual Designer. if you would not like to return to its initial position. either you can cancel the checked in Visual Designer or handle it in resize event
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
As I said, the handle resize event of the MainForm is checked as default in Visual Designer. if you would not like to return to its initial position. either you can cancel the checked in Visual Designer or handle it in resize event
It looks like this but it makes no sense. The layout should adjust automatically, having that setting set to True, but if you THEN move a View from code, it should stay in the new position.

The initial question remains, which I consider important.
 
Upvote 0

EnriqueGonzalez

Expert
Licensed User
Longtime User
Thank you for the information, but what I was asking is if there is a solution, because in this way the debugging of the graphics is difficult, at most you can use log commands.

Maybe a MyForm.Refresh, implemented by Erel?
Debugging the graphics is the incorrect approach, A refresh won't fix the underlying technology. it was build that way. you won't get any UI update because the debugger pauses all the threads.

have not used VB Net for a long time
Vb.net is based on winforms and b4x is based on javafx, they are not even close to make a comparison.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Debugging the graphics is the incorrect approach, A refresh won't fix the underlying technology
Now I need to debug the graphics; why should I consider it "wrong"? :oops: 🤬😄

Vb.net is based on winforms and b4x is based on javafx, they are not even close to make a comparison.
:oops: Wow, this is new for me 😄 (sorry, but I "live"here from 2013, I know "something").

The fact that using the following "snippet" the label is visible in the new position, demonstrates that an intervention in the B4J source could work.
In this way:
B4X:
Sub Button1_Click
 Log("stop")
 xui.MsgboxAsync("Hello World!", "B4X")

 Button1.Left = 200
 Sleep(300)
 Log("LucaMs is really stupid; it is evident from the questions he posts.")
End Sub
by putting breakpoints on the Log lines, executing the instruction with the msgbox by pressing F8 and then F5, at the next break the button actually goes to x 200 (but you struggle to find the form on the Desktop).
The fact remains that then the button returns to its initial position.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
Have try to force a refresh with sleep(0)?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Have try to force a refresh with sleep(0)?
In this way:
B4X:
Sub Button1_Click
 Log("stop")
 xui.MsgboxAsync("Hello World!", "B4X")

 Button1.Left = 200
 Sleep(300)
 Log("LucaMs is really stupid; it is evident from the questions he posts.")
End Sub
by putting breakpoints on the Log lines, executing the instruction with the msgbox by pressing F8 and then F5, at the next break the button actually goes to x 200 (but you struggle to find the form on the Desktop).
The fact remains that then the button returns to its initial position.
 
Upvote 0
Top