B4J Question Button Click Event Data

dieterp

Active Member
Licensed User
Longtime User
I have a button with a Mouse_Clicked event. I want to call the button's Mouse_Clicked event from another sub. What is the EventData that must be passed into that call? Below is the code:

B4X:
Sub btnTest_MouseClicked (EventData As MouseEvent)
   
End Sub

Sub CallButton
   
    btnTest_MouseClicked("What goes here?")
   
End Sub
 

amykonio

Active Member
Licensed User
Longtime User
Hi.

Personally I don't like writing logic in Clicked events etc. I usually create a separate sub and call this one from my Clicked event.
Anyway. If you need to call a clicked event, then you can create eventdata and give it as a param.

B4X:
Dim e As MouseEvent
   
btnTest_MouseClicked(e)

But if inside btnTest_MouseClicked you check values in EventData, then you may need to do more settings to the param you pass.

Andreas.
 
Upvote 0

amykonio

Active Member
Licensed User
Longtime User
Do you use the EventData in the Mouse_Clicked event routine?
If no, you can use Mouse_Action instead.
Actually using Action instead of Clicked, has another advantage. It works also by pressing space when the button has the focus. Clicked happens only after a mouse click.

Andreas.
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
Thanks guys. I'll try out all the options listed above and revert back if I cant find a solution
 
Upvote 0
Top