B4J Question Add ContextMenu to ImageView

Discussion in 'B4J Questions' started by Firpas, Apr 28, 2016.

  1. Firpas

    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

    Attached Files:

  2. rwblinn

    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.

    '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
    "show"Array(Button1, "RIGHT"5.010.0))
    End If
    End Sub
    Mashiane, Erel and inakigarm like this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    The reason for this is that ImageView doesn't support this feature.
  4. Firpas

    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
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice