public class CheckMenuItem extends MenuItem
A CheckMenuItem is just like a MenuItem, but additionally it displays a
"check box" alongside the normal Label, indicating the state of the boolean
value it holds. When that value is set to true
, the item is
active and the box shows the check mark.
You can use a CheckMenuItem as a way to allow users of your application enable or disable a feature in an application. This is often used within to toggle options, for example to let the user hide an optional Widget of your user interface.
The active state is switched automatically when the user activates the
MenuItem. You can access the current state with the getActive()
method. And while you can still connect to the
MenuItem.Active
signal, CheckMenuItem provides the
CheckMenuItem.Toggled
signal, emitted when the active state
changes.
See the parent
class for further details general to all
MenuItems.
Modifier and Type | Class and Description |
---|---|
static interface |
CheckMenuItem.Toggled
The handler interface for a change in the active state.
|
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 |
---|
CheckMenuItem()
Construct a CheckMenuItem
|
CheckMenuItem(String mnemonicLabel)
Construct a CheckMenuItem with a given text Label.
|
CheckMenuItem(String mnemonicLabel,
CheckMenuItem.Toggled handler)
Construct a CheckMenuItem with a given text label, and additionally
connect a handler to its
CheckMenuItem.Toggled signal. |
Modifier and Type | Method and Description |
---|---|
void |
connect(CheckMenuItem.Toggled handler)
Connect a
CheckMenuItem.Toggled handler to the Widget. |
boolean |
getActive()
Retrieve the active state of the item.
|
boolean |
getInconsistent()
Get the inconsistent state.
|
void |
setActive(boolean isActive)
Set the active state of the Item.
|
void |
setInconsistent(boolean setting)
Set the inconsistent state.
|
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 CheckMenuItem()
public CheckMenuItem(String mnemonicLabel)
_) which, if present, will indicate the
mnemonic which will activate that CheckMenuItem directly if that key is
pressed while viewing the Menu.
- Since:
- 4.0.4
-
CheckMenuItem
public CheckMenuItem(String mnemonicLabel,
CheckMenuItem.Toggled handler)
Construct a CheckMenuItem with a given text label, and additionally
connect a handler to its CheckMenuItem.Toggled
signal.
This affords you the convenience of being able to add a MenuItem fairly
compactly:
editMenu.append(new MenuItem("_Paste", new CheckMenuItem.Toggled() {
public void onToggled(MenuItem source) {
...
}
}));
- Since:
- 4.0.4
-
Method Detail
-
connect
public void connect(CheckMenuItem.Toggled handler)
Connect a CheckMenuItem.Toggled
handler to the Widget.
- Since:
- 4.0.4
-
getActive
public boolean getActive()
Retrieve the active state of the item.
- Since:
- 4.0.4
-
getInconsistent
public boolean getInconsistent()
Get the inconsistent state.
- Since:
- 4.0.4
- See Also:
setInconsistent(boolean)
-
setActive
public void setActive(boolean isActive)
Set the active state of the Item. This is switched automatically when
the user activates (clicks) the menu item, but in some situations you
will want to change it manually.
- Since:
- 4.0.4
-
setInconsistent
public void setInconsistent(boolean setting)
Set the inconsistent state. This refers to an additional
third state meaning that currently it cannot be decided what is the
active state of the item.
Think, for example, in a text editor application, in which a
CheckMenuItem is used to choose between a bold or a normal font. If the
user selects a range of text where both normal and bold fonts are being
used, the state is inconsistent, and we want to mark it in a different
way.
However, note that, while such property can be really useful in a
ToggleButton
, its utility in a CheckMenuItem is really unclear.
Notice also that this property only affects visual appearance, it
doesn't affect the semantics of the Widget.
- Since:
- 4.0.4