org.gnome.gtk
Class Menu
Object
org.freedesktop.bindings.Pointer
org.freedesktop.bindings.Proxy
org.gnome.glib.Object
org.gnome.gtk.Object
org.gnome.gtk.Widget
org.gnome.gtk.Container
org.gnome.gtk.MenuShell
org.gnome.gtk.Menu
- Direct Known Subclasses:
- RecentChooserMenu
public class Menu
- extends MenuShell
A drop-down set of Widgets creating a menu. Menus consist of other
MenuItem
s. Menus are either placed inside a MenuBar
or
another MenuItem, thereby forming a sub-menu. An entire hierarchy of Menu
structures can thus be created by appropriately placing Menus inside
MenuBars or MenuItems.
A "context menu" (a stand-alone menu which pops-up) can also be created;
this is commonly used to create a context sensitive popup menu in response
to a right-click (or left-click as the case may be); see the popup()
method.
For a broader explanation of the Menu API see MenuShell
.
GTK does have the ability to "tear" Menus off from the parent Container.
After consistently poor results in usability testing, however, tear-off
menus are now highly discouraged in the GNOME community. They are therefore
not presented in the java-gnome bindings.
- Since:
- 4.0.3
- Author:
- Sebastian Mancke, Srichand Pendyala, Andrew Cowie
Nested classes/interfaces inherited from class org.gnome.gtk.Widget |
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.EnterNotifyEvent, Widget.ExposeEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.PopupMenu, Widget.ScrollEvent, Widget.UnmapEvent, Widget.VisibilityNotifyEvent |
Constructor Summary |
Menu()
Construct a new Menu. |
Method Summary |
void |
popup()
Popup a context menu. |
void |
popup(StatusIcon status)
A special case for popping up the context menu associated with a
StatusIcon. |
Methods inherited from class org.gnome.gtk.Widget |
activate, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getRequisition, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, modifyBackground, modifyBase, modifyFont, modifyText, queueDraw, queueDrawArea, setCanDefault, setCanFocus, setColormap, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll |
Methods inherited from class org.freedesktop.bindings.Pointer |
toString |
Methods inherited from class Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Menu
public Menu()
- Construct a new Menu.
popup
public void popup()
- Popup a context menu. Use this when you create a Menu that will be used
for the popup context menu in response to a right-click somewhere. TODO
add example code showing hooking up a mouse button click handler.
Unlike normal Menus that are part of an application's MenuBar, context
menus are not mapped automatically, so you need to have
showAll()
called on them once you're done
building them to allocate their resources (otherwise you end up with a
1x1 pixel sized menu with nothing in it).
- Since:
- 4.0.3
popup
public void popup(StatusIcon status)
- A special case for popping up the context menu associated with a
StatusIcon. Having constructed a Menu to be used as the context menu,
you then call this from the
StatusIcon.PopupMenu
signal
callback as follows:
StatusIcon si;
Menu context;
...
si.connect(new StatusIcon.PopupMenu() {
public void onPopupMenu(StatusIcon source, int button, int activateTime) {
context.popup(source);
}
});
Don't forget to call showAll()
on the Menu
when you're done constructing it before trying to use it the first
time.
- Since:
- 4.0.3