Enumerations #
Name | Values |
---|---|
TriggerOn | None |
Right | |
Left | |
Hover |
Constants #
Name | Type | Value |
---|---|---|
TriggerHover | Integer | 3 |
TriggerLeft | Integer | 2 |
TriggerNone | Integer | 0 |
TriggerRight | Integer | 1 |
Events #
Definition | Description |
---|---|
MenuAction( InMenu as GraffitiMenuItem, ChildItem as GraffitiMenuItem ) | Fires when the user selects an item from a displayed menu. |
MenuHidden( Menu as GraffitiMenuItem ) | Fired when the menu is hidden. |
MenuShown( Menu as GraffitiMenuItem ) | Fires when a menu becomes visible. |
Methods #
Definition | Parameters | Return Type | Description |
---|---|---|---|
AddMenu | theMenu as GraffitiMenuItem | None | 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 | None | Binds a menu to a control. |
Trigger as TriggerOn | |||
theMenu as GraffitiMenuItem | |||
AutoHide as Boolean = False | |||
Position as REALbasic.Point = nil | |||
AddMenu | theControl as WebListBox | None | Attaches the specified menu to the WebListBox instance provided. |
theMenu as GraffitiMenuItem | |||
AutoHide as Boolean = False | |||
HideMenu | theMenu as GraffitiMenuItem | 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 | GraffitiMenuItem | Returns the GraffitiMenu currently managed by the component instance at the specified index. |
MenuByName | menuName as String | GraffitiMenuItem | Returns the first GraffitiMenu 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 GraffitiMenuItem | 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
GraffitiToolbar #
The easiest method to add a GraffitiMenu to a GraffitiToolbarButton is to first create your menu:
dim EditMenuItem as new GraffitiMenuItem( "AddMenu" ) EditMenuItem.Children.Append( new GraffitiMenuItem( "text", "Plain Text" ) ) EditMenuItem.Children.Append( new GraffitiMenuItem( "undo", "Undo", "fa fa-undo", false, "u" ) ) EditMenuItem.Children.Append( new GraffitiMenuItem( True ) ) EditMenuItem.Children.Append( new GraffitiMenuItem( "cut", "Cut", "fa fa-cut", false, "t" ) ) EditMenuItem.Children.Append( new GraffitiMenuItem( "copy", "Copy", "fa fa-copy", false, "c" ) ) EditMenuItem.Children.Append( new GraffitiMenuItem( "paste", "Paste", "fa fa-paste", True, "p" ) ) EditMenuItem.Children.Append( new GraffitiMenuItem( "delete", "Delete", "fa fa-times", false, "d" ) ) EditMenuItem.Children.Append( new GraffitiMenuItem( True ) ) EditMenuItem.Children.Append( new GraffitiMenuItem( "selall", "Select All", "fa fa-i-cursor", false, "s" ) ) EditMenuItem.Children.Append( new GraffitiMenuItem( True ) )
Then call the AddMenu method of GraffitiMenu that accepts a GraffitiToolbarButton parameter which has the following signature:
AddMenu( ToolbarItem as GraffitiToolbarButton, theMenu as GraffitiMenuItem, Trigger as Integer, AutoHide as Boolean = False, Position as REALbasic.Point = nil )
As:
gcmPopups.AddMenu( tlbAdd, EditMenuItem, GraffitiMenu.TriggerHover, True )
Styles #
GraffitiMenuItems 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 GraffitiMenuItem( "unattachedMenu" ) unattachedMenu.Children.Append( new GraffitiMenuItem( "unattached1", "Item 1" ) ) unattachedMenu.Children.Append( new GraffitiMenuItem( "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.