B4J Question How to get the Calling view from a context menu click

Pxs

Member
Licensed User
Hello

I'm trying to get the calling view upon selection of a context menu entry

Context menu(from the editor):

B4X:
[
    {
        Text:"Detailed Info",
        EventName : "ShowDetailedInfo"
    }
]

Called sub:
B4X:
Private Sub ShowDetailedInfo_Action
    Dim mi As MenuItem = Sender
End Sub

I know i can store info in the "tag" field, but i have a complicated layout with many runtime generated views, so i was hoping to the the caller view (the one i right-clicked on) and then go up the tree with .parent to update the holding panels.

Is it even possible?

Thanks!
 
Solution
Found the solution:

Save the the view in a global variable upon click event
B4X:
Private Sub ClvField_MouseClicked (EventData As MouseEvent)
    Dim LastClickedClvField As B4XView = Sender
End Sub

...and then access it later, when the user selects from the context menu and triggers its action

B4X:
Private Sub ShowDetailedInfo_Action
    LastClickedClvField.Parent.SetColorAnimated(500,xui.Color_Yellow,xui.Color_Cyan)
End Sub

Pxs

Member
Licensed User
Found the solution:

Save the the view in a global variable upon click event
B4X:
Private Sub ClvField_MouseClicked (EventData As MouseEvent)
    Dim LastClickedClvField As B4XView = Sender
End Sub

...and then access it later, when the user selects from the context menu and triggers its action

B4X:
Private Sub ShowDetailedInfo_Action
    LastClickedClvField.Parent.SetColorAnimated(500,xui.Color_Yellow,xui.Color_Cyan)
End Sub
 
Upvote 0
Solution
Top