B4J Question Add ContextMenu to ImageView

Firpas

Active Member
Licensed User
I´ve seen in Internal Designer, that ImageView has not the property ContextMenu, then i need to add this by code with ContextMenu and Menuitem objects, but ....

How to add menuitems to a menuitems to create cascading context menu??
How to set the menuitem selected (checked) or not?
How to add separators?
How to set shotrcuts?


Is possible to create a ContextMenu from Json string by code like Internal Designer??

Thanks in advance
 

Attachments

  • MnuItem.png
    MnuItem.png
    9.4 KB · Views: 187

rwblinn

Well-Known Member
Licensed User
A workaround is using a ContextMenu from f.e. a Button and assign the Button Contextmenu to the ImageView.

B4X:
'Handle ImageView MouseClick
'When right click open a contextmenu which is assigned to a button. 
'The imageview has no contextmenu property - using it from a button is a workaround. 
'The button is invisible and its position is the same as the imageview.
'Requires the JavaObject Library.
Sub ImageView1_MouseClicked (EventData As MouseEvent)
    If EventData.SecondaryButtonPressed Then
        Dim joContextMenu As JavaObject = Button1.ContextMenu
        joContextMenu.RunMethod("show", Array(Button1, "RIGHT", 5.0, 10.0))
    End If
End Sub
 
Upvote 0

Firpas

Active Member
Licensed User
Ok thanks for yours replays

I think i`ll do rwblinn solution but with a label without text instead a button.

Thanks again
 
Upvote 0
Top