B4J Question Detect Move B4XPage?

mw71

Active Member
Licensed User
Longtime User
hi

there is the function B4XPage_Resize, which works well.
Is there a way to recognize that the B4XPage has been moved without changing the size?
 

TILogistic

Expert
Licensed User
Longtime User
?
What is a B4XPage?

It differs between the three platforms:
B4J - Form
B4i - Page in a single NavBarController
B4A - Panel in a single activity.

 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Is there a way to recognize that the B4XPage has been moved without changing the size?
If you mean "Is there a (B4J) event that fires when the form is moved?" then the answer is "No". However you can setup a timer that monitors the position of the form (top and left positions) and fires when this is changed. I have tried this and it works quite well, but remember that it might fire several times if the form is being dragged.
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
If you mean "Is there an event that fires when the form is moved?" then the answer is "No".
You can with the code published by @stevel05 and that I linked in the second post.
Obviously it only works with b4j forms which is certainly what @mw71 wants to achieve.
@stevel05 code:
Private Sub SetMoveListener(Form As JavaObject)
    Dim Stage As JavaObject = Form.GetField("stage")
    Dim XProp As JavaObject = Stage.RunMethod("xProperty",Null)
    Dim YProp As JavaObject = Stage.RunMethod("yProperty",Null)
 
    Dim O As Object = Form.CreateEventFromUI("javafx.beans.value.ChangeListener","FormMoved",Null)
    XProp.RunMethod("addListener",Array(O))
    YProp.RunMethod("addListener",Array(O))
End Sub

Private Sub FormMoved_Event (MethodName As String, Args() As Object) As Object
    Dim F As Form = Sender
    Log("Form moved " & F.WindowLeft & " : " & F.WindowTop)
End Sub
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You can with the code published by @stevel05 and that I linked in the second post.





Project attached (it also contains superfluous things, it is based on a project template - to be improved).

Of course you can move any B4XPage-Form, even the B4XMainPage, and use the coordinates in the Form itself, instead of passing this data to the main page, as I did in the example.
 

Attachments

  • B4XPageMovem.zip
    15.5 KB · Views: 10
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…