B4J Question How to change mouse cursor while program is busy [solved]

Didier9

Well-Known Member
Licensed User
Longtime User
Some tasks take a while and I would like to change the cursor to the hourglass cursor so the user knows something is going on.
Not sure how to do that.
TIA
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Thank you Don, I think it is getting close, but in the context of the proposed code:

B4X:
Dim cursor As JavaObject
cursor.InitializeStatic("javafx.scene.Cursor")   

Dim joObj as JavaObject = ap
joObj.RunMethod("setCursor", Array(cursor.GetField("E_RESIZE")))

what is "ap"?

PS: I did use Search but probably did not use the proper keywords and did not see that post...
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Turns out it is working but not necessarily as you would expect.
If the cursor is changed and changed back to default within a function block, the cursor on screen will not actually change. Simply inserting Sleep(0) after the first command did not seem enough to allow java to actually change the cursor but maybe because the delay between the two commands is too short at the moment.

Is there another way to force the screen to be redrawn with the new cursor?

PS: I changed the Sleep(0) to Sleep(500) and definitely the cursor changes :) I call this victory!
 
Upvote 0
Top