B4J Question [SOLVED] How to implement Right-Click on Toggle Button

GuyBooth

Active Member
Licensed User
Longtime User
I have several toggle buttons which when clicked raise a common event. This is done by setting their Event Name in the Designer to "tglState", and creating this event in the code:
B4X:
Sub tglState_Click
    Dim TglBtn As ToggleButton
    TglBtn = Sender
    … code to process desired actions on this click event

end sub
The Toggle Button does not have "built-in" MouseEvent eventdata, such as would be available with a Label, but I need to be able to determine whether the Right or Left button was clicked and process accordingly.
My efforts to apply a listener have so far been complicated, clumsy, and only work on individual ToggleButtons, not with this code using a "Sender".
Is there a simple way to add a mouse event parameter to the Click event of a Toggle Button?
If not, how do I add a listener to work with this event code that is common to several Toggle Buttons?

[UPDATE] Ouch! Just found out that tglState_MouseClicked (Eventdata as MouseEvent) works and gives me what I need.
 
Last edited:
Top