Criar  Editar  FrontPage  Índices  Buscar  Alterações  History  RSS  Login


class Gtk::MenuShell

A Gtk::MenuShell is the abstract base class used to derive the Gtk::Menu and Gtk::MenuBar subclasses.

A Gtk::MenuShell is a container of Gtk::MenuItem objects arranged in a list which can be navigated, selected, and activated by the user to perform application functions. A Gtk::MenuItem can have a submenu associated with it, allowing for nested hierarchical menus.

Instance Methods

Adds a new Gtk::MenuItem to the end of the menu shell's item list.
Adds a new Gtk::MenuItem to the beginning of the menu shell's item list.
insert(child, position)
Adds a new Gtk::MenuItem to the menu shell's item list at the position indicated by position.
  • child: The Gtk::MenuItem to add.
  • position: The position in the item list where child is added. Positions are numbered from 0 to n-1.
  • Returns: self
Deactivates the menu shell. Typically this results in the menu shell being erased from the screen.
  • Returns: self
Selects the menu item from the menu shell.
Deselects the currently selected item from the menu shell, if any.
  • Returns: self
Activates the menu item within the menu shell.
  • menu_item: The Gtk::MenuItem to activate.
  • force_deactivate: If true, force the deactivation of the menu shell after the menu item is activated.
Returns true if the menu shell will take the keyboard focus on popup. Since 2.8
If take_focus is true (the default) the menu shell will take the keyboard focus so that it will receive all keyboard events which is needed to enable keyboard navigation in menus. Setting take_focus to false is useful only for special applications like virtual keyboard implementations which should not take keyboard focus. The take_focus state of a menu or menu bar is automatically propagated to submenus whenever a submenu is popped up, so you don't have to worry about recursively setting it for your entire menu hierarchy. Only when programmatically picking a submenu and popping it up manually, the take-focus property of the submenu needs to be set explicitely. Note that setting it to false has side-effects: if the focus is in some other app, it keeps the focus and keynav in the menu doesn't work. Consequently, keynav on the menu will only work if the focus is on some toplevel owned by the onscreen keyboard. To avoid confusing the user, menus with take_focus set to false should not display mnemonics or accelerators, since it cannot be guaranteed that they will work. See also Gdk#Gdk.keyboard_grab?. Since 2.8
  • take_focus: true if the menu shell should take the keyboard focus on popup.
  • returns: take_focus
Same as Gtk::MenuShell#take_focus=(take_focus). Since 2.8
  • returns: self



To the parent menu shell.
To the submenu, if any, associated with the item.
To the next menu item.
To the previous menu item.


take-focus: true or false (Read/Write)
A boolean that determines whether the menu and its submenus grab the keyboard focus. See Gtk::MenuShell#take_focus= and Gtk::MenuShell#take_focus. Since 2.8


activate-current: self, force_hide
An action signal that activates the current menu item within the menu shell.
  • self: Gtk::MenuShell
  • force_hide: if true, hide the menu after activating the menu item.
cancel: self
An action signal which cancels the selection within the menu shell. Causes the GtkMenuShell::selection-done signal to be emitted.
cycle-focus: self, direction
deactivate: self
This signal is emitted when a menu shell is deactivated.
move-current: self, direction
An action signal which moves the current menu item in the direction specified by direction.
selection-done: self
This signal is emitted when a selection has been completed within a menu shell.

- Masao?

Last modified:2005/11/17 02:43:41
References:[Gtk::MenuBar] [Gtk::Menu] [Gtk::OptionMenu] [Gtk::HSeparator] [Gtk::RecentChooserMenu] [Gtk::MenuItem] [Gtk::MenuShell] [Vte::Terminal]