MenuItem

Instances of this class represent a selectable user interface object that issues notification when pressed and released. <dl> <dt><b>Styles:</b></dt> <dd>CHECK, CASCADE, PUSH, RADIO, SEPARATOR</dd> <dt><b>Events:</b></dt> <dd>Arm, Help, Selection</dd> </dl> <p> Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO and SEPARATOR may be specified. </p><p> IMPORTANT: This class is <em>not</em> intended to be subclassed. </p>

@see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

Constructors

this
this(Menu parent, int style)

Constructs a new instance of this class given its parent (which must be a <code>Menu</code>) and a style value describing its behavior and appearance. The item is added to the end of the items maintained by its parent. <p> The style value is either one of the style constants defined in class <code>SWT</code> which is applicable to instances of this class, or must be built by <em>bitwise OR</em>'ing together (that is, using the <code>int</code> "|" operator) two or more of those <code>SWT</code> style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses. </p>

this
this(Menu parent, int style, int index)

Constructs a new instance of this class given its parent (which must be a <code>Menu</code>), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent. <p> The style value is either one of the style constants defined in class <code>SWT</code> which is applicable to instances of this class, or must be built by <em>bitwise OR</em>'ing together (that is, using the <code>int</code> "|" operator) two or more of those <code>SWT</code> style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses. </p>

Members

Functions

addAccelerator
void addAccelerator(GtkAccelGroup* accelGroup)
Undocumented in source. Be warned that the author may not have intended to support it.
addAccelerators
void addAccelerators(GtkAccelGroup* accelGroup)
Undocumented in source. Be warned that the author may not have intended to support it.
addArmListener
void addArmListener(ArmListener listener)

Adds the listener to the collection of listeners who will be notified when the arm events are generated for the control, by sending it one of the messages defined in the <code>ArmListener</code> interface.

addHelpListener
void addHelpListener(HelpListener listener)

Adds the listener to the collection of listeners who will be notified when the help events are generated for the control, by sending it one of the messages defined in the <code>HelpListener</code> interface.

addSelectionListener
void addSelectionListener(SelectionListener listener)

Adds the listener to the collection of listeners who will be notified when the menu item is selected by the user, by sending it one of the messages defined in the <code>SelectionListener</code> interface. <p> When <code>widgetSelected</code> is called, the stateMask field of the event object is valid. <code>widgetDefaultSelected</code> is not called. </p>

checkSubclass
void checkSubclass()
Undocumented in source. Be warned that the author may not have intended to support it.
createHandle
void createHandle(int index)
Undocumented in source. Be warned that the author may not have intended to support it.
fixMenus
void fixMenus(Decorations newParent)
Undocumented in source. Be warned that the author may not have intended to support it.
getAccelGroup
GtkAccelGroup* getAccelGroup()
Undocumented in source. Be warned that the author may not have intended to support it.
getAccelerator
int getAccelerator()

Returns the widget accelerator. An accelerator is the bit-wise OR of zero or more modifier masks and a key. Examples: <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>. The default value is zero, indicating that the menu item does not have an accelerator.

getBounds
Rectangle getBounds()
Undocumented in source. Be warned that the author may not have intended to support it.
getEnabled
bool getEnabled()

Returns <code>true</code> if the receiver is enabled, and <code>false</code> otherwise. A disabled menu item is typically not selectable from the user interface and draws with an inactive or "grayed" look.

getMenu
Menu getMenu()

Returns the receiver's cascade menu if it has one or null if it does not. Only <code>CASCADE</code> menu items can have a pull down menu. The sequence of key strokes, button presses and/or button releases that are used to request a pull down menu is platform specific.

getNameText
String getNameText()
Undocumented in source. Be warned that the author may not have intended to support it.
getParent
Menu getParent()

Returns the receiver's parent, which must be a <code>Menu</code>.

getSelection
bool getSelection()

Returns <code>true</code> if the receiver is selected, and false otherwise. <p> When the receiver is of type <code>CHECK</code> or <code>RADIO</code>, it is selected when it is checked.

gtk_activate
int gtk_activate(GtkWidget* widget)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_select
int gtk_select(int item)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_show_help
int gtk_show_help(GtkWidget* widget, ptrdiff_t helpType)
Undocumented in source. Be warned that the author may not have intended to support it.
hookEvents
void hookEvents()
Undocumented in source. Be warned that the author may not have intended to support it.
isEnabled
bool isEnabled()

Returns <code>true</code> if the receiver is enabled and all of the receiver's ancestors are enabled, and <code>false</code> otherwise. A disabled menu item is typically not selectable from the user interface and draws with an inactive or "grayed" look.

releaseChildren
void releaseChildren(bool destroy)
Undocumented in source. Be warned that the author may not have intended to support it.
releaseParent
void releaseParent()
Undocumented in source. Be warned that the author may not have intended to support it.
releaseWidget
void releaseWidget()
Undocumented in source. Be warned that the author may not have intended to support it.
removeAccelerator
void removeAccelerator(GtkAccelGroup* accelGroup)
Undocumented in source. Be warned that the author may not have intended to support it.
removeAccelerators
void removeAccelerators(GtkAccelGroup* accelGroup)
Undocumented in source. Be warned that the author may not have intended to support it.
removeArmListener
void removeArmListener(ArmListener listener)

Removes the listener from the collection of listeners who will be notified when the arm events are generated for the control.

removeHelpListener
void removeHelpListener(HelpListener listener)

Removes the listener from the collection of listeners who will be notified when the help events are generated for the control.

removeSelectionListener
void removeSelectionListener(SelectionListener listener)

Removes the listener from the collection of listeners who will be notified when the control is selected by the user.

selectRadio
void selectRadio()
Undocumented in source. Be warned that the author may not have intended to support it.
setAccelerator
void setAccelerator(int accelerator)

Sets the widget accelerator. An accelerator is the bit-wise OR of zero or more modifier masks and a key. Examples: <code>SWT.MOD1 | SWT.MOD2 | 'T', SWT.MOD3 | SWT.F2</code>. <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>. The default value is zero, indicating that the menu item does not have an accelerator.

setEnabled
void setEnabled(bool enabled)

Enables the receiver if the argument is <code>true</code>, and disables it otherwise. A disabled menu item is typically not selectable from the user interface and draws with an inactive or "grayed" look.

setImage
void setImage(Image image)

Sets the image the receiver will display to the argument. <p> Note: This operation is a hint and is not supported on platforms that do not have this concept (for example, Windows NT). </p>

setMenu
void setMenu(Menu menu)

Sets the receiver's pull down menu to the argument. Only <code>CASCADE</code> menu items can have a pull down menu. The sequence of key strokes, button presses and/or button releases that are used to request a pull down menu is platform specific. <p> Note: Disposing of a menu item that has a pull down menu will dispose of the menu. To avoid this behavior, set the menu to null before the menu item is disposed. </p>

setOrientation
void setOrientation()
Undocumented in source. Be warned that the author may not have intended to support it.
setRadioSelection
bool setRadioSelection(bool value)
Undocumented in source. Be warned that the author may not have intended to support it.
setSelection
void setSelection(bool selected)

Sets the selection state of the receiver. <p> When the receiver is of type <code>CHECK</code> or <code>RADIO</code>, it is selected when it is checked.

setText
void setText(String string)

Sets the receiver's text. The string may include the mnemonic character and accelerator text. <p> Mnemonics are indicated by an '&amp;' that causes the next character to be the mnemonic. When the user presses a key sequence that matches the mnemonic, a selection event occurs. On most platforms, the mnemonic appears underlined but may be emphasised in a platform specific manner. The mnemonic indicator character '&amp;' can be escaped by doubling it in the string, causing a single '&amp;' to be displayed. </p> <p> Accelerator text is indicated by the '\t' character. On platforms that support accelerator text, the text that follows the '\t' character is displayed to the user, typically indicating the key stroke that will cause the item to become selected. On most platforms, the accelerator text appears right aligned in the menu. Setting the accelerator text does not install the accelerator key sequence. The accelerator key sequence is installed using #setAccelerator. </p>

updateAccelerator
void updateAccelerator(GtkAccelGroup* accelGroup, bool add)
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

checkStyle
int checkStyle(int style)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

accelerator
int accelerator;
Undocumented in source.
groupHandle
GtkAccelGroup* groupHandle;
menu
Menu menu;
Undocumented in source.
parent
Menu parent;
Undocumented in source.

Inherited Members

From Item

text
String text;
Undocumented in source.
image
Image image;
Undocumented in source.
checkSubclass
void checkSubclass()
Undocumented in source. Be warned that the author may not have intended to support it.
getImage
Image getImage()

Returns the receiver's image if it has one, or null if it does not.

getNameText
String getNameText()
Undocumented in source. Be warned that the author may not have intended to support it.
getText
String getText()

Returns the receiver's text, which will be an empty string if it has never been set.

releaseWidget
void releaseWidget()
Undocumented in source. Be warned that the author may not have intended to support it.
setImage
void setImage(Image image)

Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.

setText
void setText(String string)

Sets the receiver's text.

Meta