Menu

The cascading menu that items are selected from.

Constructors

this
this()

Construct the widget.

this
this(MenuBar parent, string label, ubyte underlineChar)

Construct the widget.

Members

Functions

addCheckButtonEntry
auto addCheckButtonEntry(string label, CommandCallback callback, string shortCutText)

Add an item to the menu that when selected adds a checked icon.

addCheckButtonEntry
auto addCheckButtonEntry(Image image, string label, CommandCallback callback, string imagePosition, string shortCutText)

Add an item to the menu with an image that when selected adds a checked icon.

addEntry
auto addEntry(string label, CommandCallback callback, string shortCutText)

Add an item to the menu.

addEntry
auto addEntry(Image image, string label, CommandCallback callback, string imagePosition, string shortCutText)

Add an item to the menu with an image.

addMenuEntry
auto addMenuEntry(string label, Menu menu, ubyte underlineChar)

Add a cascade menu to this menu.

addRadioButtonEntry
auto addRadioButtonEntry(string label, CommandCallback callback, string shortCutText)

Add an item to the menu that acts as a radio button.

addRadioButtonEntry
auto addRadioButtonEntry(Image image, string label, CommandCallback callback, string imagePosition, string shortCutText)

Add an item to the menu with an image that acts as a radio button.

addSeparator
auto addSeparator()

Add a separator to the menu.

disableEntry
auto disableEntry(int index)

Disable a menu item. The item indexes start at zero for the top-most entry and increase as you go down. Index refers to all menu items including separators.

enableEntry
auto enableEntry(int index)

Enable a menu item. The item indexes start at zero for the top-most entry and increase as you go down. Index refers to all menu items including separators.

getSelectedRadioEntryValue
string getSelectedRadioEntryValue()

Get the value of the selected radio button entry. This value will be the same as the entry's label. This method will return an empty string if no radio button entry exists or none are selected.

invoke
auto invoke(int index)

Invoke a menu item by its index. The item indexes start at zero for the top-most entry and increase as you go down. Index refers to all menu items including separators.

isCheckBoxEntrySelected
bool isCheckBoxEntrySelected(int index)

Get if the check box entry at the passed index is checked or not. The index only applies to check box entries in the menu not any other type of entry. If there are no check box entries in the menu this method returns false.

popup
auto popup(int xPos, int yPos)

Show the menu.

Inherited Members

From UiElement

getClass
string getClass()

Get the widget's class.

setCursor
auto setCursor(string cursor)

Set the widget's cursor.

getCursor
string getCursor()

Get the widget's cursor.

bind
auto bind(string binding, CommandCallback callback)

Bind a callback to a particular event triggered by this element.

unbind
auto unbind(string binding)

Unbind a previous event binding.

destroy
void destroy()

Destroy this element and remove it from the GUI.

getChildIds
string[] getChildIds()

Get the string id's of the immediate children elements.

getWidth
int getWidth()

Get the width of the element.

getHeight
int getHeight()

Get the height of the element.

hwnd
size_t hwnd [@property getter]

Get the platform specific window id. This is equal to the hwnd on Windows or the x11 window id on Linux.

getCursorPos
int[] getCursorPos()

Get the position of the cursor over the element. The cursor position returned is relative to the screen. It is only returned if the cursor is over the element.

getCursorXPos
int getCursorXPos()

Get the horizontal position of the cursor over the element. The cursor position returned is relative to the screen. It is only returned if the cursor is over the element.

getCursorYPos
int getCursorYPos()

Get the vertical position of the cursor over the element. The cursor position returned is relative to the screen. It is only returned if the cursor is over the element.

getScreenWidth
int getScreenWidth()

Get the width of the screen this element is displayed on.

getScreenHeight
int getScreenHeight()

Get the height of the screen this element is displayed on.

getXPos
int getXPos(bool relativeToParent)

Get the horizontal position of the element. The number returned is calculated using the top, left-most pixel of the element including border if one exists.

getYPos
int getYPos(bool relativeToParent)

Get the vertical position of the element. The number returned is calculated using the top, left-most pixel of the element including border if one exists.

enableGeometryAutoSize
auto enableGeometryAutoSize(bool enable)

Set if the element should change it size when requested to do so by a geometry manager.

configureGeometryColumn
auto configureGeometryColumn(int index, int weight, int minSize, int uniformGroup, int pad)

Used by the grid geometry manager. Sets options for grid columns that contain child widgets.

configureGeometryRow
auto configureGeometryRow(int index, int weight, int minSize, int uniformGroup, int pad)

Used by the grid geometry manager. Sets options for grid rows that contain child widgets.

setBusy
auto setBusy(bool busy, string cursor)

Provides a simple means to block keyboard, button, and pointer events from elements, while overriding the cursor with a configurable busy cursor.

isBusy
bool isBusy()

Gets if the element is busy or not.

generateEvent
void generateEvent(string event)

Generates an event and arranges for it to be processed just as if it had come from the operating system. Event provides a basic description of the event, such as <Shift-Button-2> or <<Paste>>. The event argument may have any of the forms allowed for the binding argument of the bind method except that it must consist of a single event pattern only. Certain events, such as key events, require that the window has focus to receive the event properly.

focus
auto focus(bool force)

Set the element to take focus so any key press or key release events for the application are sent to that element. It is also possible to force the operating system to apply focus to the element immediately.

setGrab
auto setGrab(bool enable, bool global)

This command implements simple pointer and keyboard grabs. When a grab is set for a particular element, it restricts all pointer events to the grab window and its descendants. Whenever the pointer is within the grab element, the pointer will behave exactly the same as if there had been no grab at all and all events will be reported in the normal fashion. When the pointer is outside the element, button presses, releases and mouse motion events are reported to the element, and element entry and exit events are ignored. The grab 'owns' the pointer: elements outside the grab will be visible on the screen but they will be insensitive until the grab is released. The tree of elements underneath the grab element can include windows, in which case all windows and their descendants will continue to receive mouse events during the grab.

isGrabbing
bool isGrabbing()

Gets if the element is currently grabbing all events or not.

lower
auto lower(UiElement element)

Lower a window's position in the stacking order.

raise
auto raise(UiElement element)

Raise a window's position in the stacking order.

Examples

auto menu = new Menu()
	.addEntry("Entry 1", delegate(CommandArgs args){ ... })
	.addEntry("Entry 2", delegate(CommandArgs args){ ... })
	.addSeparator()
	.addEntry("Entry 3", delegate(CommandArgs args){ ... });

Additional Events

Additional events that can also be bound to using the bind method.

<<MenuSelect>>, <<PrevWindow>>, <Alt-Key>, <Button>, <ButtonRelease>, <Enter> <Key-Down>, <Key-Escape>, <Key-F10>, <Key-Left>, <Key-Return>, <Key-Right>, <Key-Tab>, <Key-Up>, <Key-space>, <Key>, <Leave>, <Motion>,

See Also

Meta