public class MenuItem extends Bin implements Activatable
MenuItems can be either left justified or right justified, but in general you should just leave this alone and it will do the right thing for your locale (left aligned for western languages, right aligned for right-to-left languages like Arabic).
Right justification was initially designed to be used for "Help" Menus, but this is now considered a bad idea and is no longer used in GNOME.
Modifier and Type | Class and Description |
---|---|
static interface |
MenuItem.Activate
The handler interface for an activation.
|
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
Constructor and Description |
---|
MenuItem()
Construct a MenuItem
|
MenuItem(String mnemonicLabel)
Construct a MenuItem with a given text label.
|
MenuItem(String mnemonicLabel,
MenuItem.Activate handler)
Construct a MenuItem with a given text label, and additionally connect
a handler to its
MenuItem.Activate signal. |
Modifier and Type | Method and Description |
---|---|
void |
connect(MenuItem.Activate handler)
Connect an
MenuItem.Activate handler to the widget. |
Action |
getRelatedAction()
Get the Action that is triggered when this Activatable is activated, if
any.
|
Widget |
getSubmenu()
Returns the submenu underneath this menu item, if any
|
void |
setAccelerator(AcceleratorGroup group,
Keyval keyval,
ModifierType modifier)
Set a key binding for this MenuItem.
|
void |
setRelatedAction(Action action)
Set the Action that is triggered when this Activatable is activated.
|
void |
setSubmenu(Menu child)
Sets or replaces the MenuItem's submenu, or removes it if a
null Menu is passed. |
add, getChildren, remove, setBorderWidth
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
public MenuItem()
public MenuItem(String mnemonicLabel)
_
character) which, if present, will
indicate the mnemonic which will activate that MenuItem directly if
that key is pressed (whilst the Menu is showing, obviously).public MenuItem(String mnemonicLabel, MenuItem.Activate handler)
MenuItem.Activate
signal.
This is equivalent to:
item = new MenuItem("_My menu item"); item.connect(handler);and affords you the convenience of being able to add a MenuItem fairly compactly:
Menu editMenu; editMenu.append(new MenuItem("_Paste", new MenuItem.Activate() { public void onActivate(MenuItem source) { ... } }));
public void connect(MenuItem.Activate handler)
MenuItem.Activate
handler to the widget.public Action getRelatedAction()
Activatable
getRelatedAction
in interface Activatable
public Widget getSubmenu()
null
if none.public void setAccelerator(AcceleratorGroup group, Keyval keyval, ModifierType modifier)
public void setRelatedAction(Action action)
Activatable
This replaced Action's connectProxy().
setRelatedAction
in interface Activatable
public void setSubmenu(Menu child)
null
Menu is passed.