See Also

Enumerations

Name Values
This class exposes no enumerations.

Constants

Name Type Value
TriggerHover Integer 3
TriggerLeft Integer 2
TriggerNone Integer 0
TriggerRight Integer 1

Events

Definition Description
MenuAction( InMenu as GraffitiWebContextMenuItem, ChildItem as GraffitiWebContextMenuItem ) Fires when the user selects an item from a displayed menu.
MenuHidden( Menu as GraffitiWebContextMenuItem ) Fired when the menu is hidden.
MenuShown( Menu as GraffitiWebContextMenuItem ) Fires when a menu becomes visible.

Methods

Definition Parameters Return Type Description
AddMenu theMenu as GraffitiWebContextMenuItem Adds an “Unattached” context menu, which can displayed anywhere and from any control.
AutoHide as Boolean = False
Position as REALbasic.Point = Nil
AddMenu theControl as WebControl Binds a menu to a control.
Trigger as Integer
theMenu as GraffitiWebContextMenuItem
AutoHide as Boolean = False
Position as REALbasic.Point = nil
AddMenu ToolbarItem as GraffitiWebToolbarButton Binds the contextmenu to the specified GraffitiWebToolbarButton.
theMenu as GraffitiWebContextMenuItem
Trigger as Integer
AutoHide as Boolean = False
Position as REALbasic.Point = nil
HideMenu theMenu as GraffitiWebContextMenuItem Hides the menu with the specified ID, if it is currently visible.
HideMenu theControl as WebControl Hides the menu for theControl, if it is currently visible.
MenuAt menuIndex as Integer GraffitiWebContextMenuItem Returns the GraffitiWebContextMenu currently managed by the component instance at the specified index.
MenuByName menuName as String GraffitiWebContextMenuItem Returns the first GraffitiWebContextMenu currently managed by the component instance with the specified name.
MenuLastIndex Integer Returns the maximum index of items managed by this instance.
ShowMenu theMenu as GraffitiWebContextMenuItem Shows the specified menu, at the specified coordinates. If both are -1, will show at cursor.
X as Integer = -1
Y as Integer = -1
ShowMenu theControl as WebControl Shows the menu for theControl, at the specified coordinates. If both are -1, will show at cursor.
X as Integer = -1
Y as Integer = -1
Unbind toolbarItem as GraffitiWebToolbarItem Removes the menu from the specified GraffitiWebToolbarItem
Unbind theControl as WebControl Removes the menu from the specified WebControl

Properties

Name Type Default Value Description
This classes exposes no properties.

Examples

Xojo WebListBox

To implement in the MouseUp event, you must provide the X and Y parameters for where the menu should appear.

if Details.Button = 2 then
  gwcmDemo.ShowMenu( me, me.left + X, me.top + Y )
end if

Styles

GraffitiWebContextMenuItems have a Style property, to which you can assign a WebStyle. If this is the top-level item used in the AddMenu call, then that style is used to style the backdrop of the contextmenu and all sub-menus. If it is an item within the top-level or sub- menu, then it is used to style the individual item.

Unbound Menus

To create an unbound menu (one which is not attached to a control), you simply call the AddMenu overloaded method:

dim unattachedMenu as new GraffitiWebContextMenuItem( "unattachedMenu" )
unattachedMenu.Children.Append( new GraffitiWebContextMenuItem( "unattached1", "Item 1" ) )
unattachedMenu.Children.Append( new GraffitiWebContextMenuItem( "unattached2", "Item 2" ) )
gwcmDemo.AddMenu( "unattachedMenu", unattachedMenu )

And to show this menu:

gwcmDemo.ShowMenu( "unattachedMenu" )

This method is recommended for instances where you wish to have multiple menus tied to a single control.