public class ImageMenuItem extends MenuItem
See Action's createMenuItem()
; you
frequently need to do a UI activity from more than one place and Action
will (among other things) generate the ImageMenuItem for a given Stock
item. See also Button's setImage()
for a
discussion of the relationship between Images and Label text.
MenuItem.Activate
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 |
---|
ImageMenuItem(Image image,
String label)
Create a MenuItem displaying an image next to text.
|
ImageMenuItem(Image image,
String label,
MenuItem.Activate handler)
Create a MenuItem displaying an image next to text, and hook up an
MenuItem.Activate handler at the same time. |
ImageMenuItem(Stock stock)
Create a MenuItem displaying a stock icon image.
|
ImageMenuItem(Stock stock,
MenuItem.Activate handler)
Convenience constructor, allowing you to create a MenuItem displaying a
stock icon while simultaneously hooking up the handler which will take
its
MenuItem.Activate signals. |
Modifier and Type | Method and Description |
---|---|
void |
setAccelerator(AcceleratorGroup group)
Activate the key binding that comes with the stock configuration, for
the case that this ImageMenuItem was constructed using a Stock item.
|
void |
setAlwaysShowImage(boolean setting)
Force the icon accompanying this ImageMenuItem to always be shown,
overriding the setting inherited from GtkSettings and GNOME.
|
void |
setImage(Image image)
Set the Image that will be used as an icon beside the text in the
ImageMenuItem.
|
connect, getRelatedAction, getSubmenu, setAccelerator, setRelatedAction, setSubmenu
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 ImageMenuItem(Image image, String label)
Don't use an empty string as a label! Users can turn off display of icons in menus, and if they do you'll end up with a MenuItem with "nothing" in it.
There is also a constructor which allows you to connect an
MenuItem.Activate
handler in-line, see
here
.
public ImageMenuItem(Image image, String label, MenuItem.Activate handler)
MenuItem.Activate
handler at the same time.public ImageMenuItem(Stock stock)
public ImageMenuItem(Stock stock, MenuItem.Activate handler)
MenuItem.Activate
signals.public void setAccelerator(AcceleratorGroup group)
public void setAlwaysShowImage(boolean setting)
As at GNOME 2.28, the default was changed by the `control-center` hackers to not show menu and button icons. This is very inconvenient, so you'll find yourself needing to call this frequently.
public void setImage(Image image)
Be aware that there are system wide settings which allow a user to turn off icons appearing in menus. Since there is always a chance that the "image" Widget being added will be hidden, don't create an ImageMenuItem with an empty label.