gtkmm: Gtk::Accelerator Namespace Reference
Utilities for keyboard accelerators. More...
Functions | |
bool | valid (guint keyval, Gdk::ModifierType modifiers) |
Determines whether a given keyval and modifier mask constitute a valid keyboard accelerator. More... | |
bool | parse (const Glib::ustring& accelerator, guint& accelerator_key, Gdk::ModifierType& accelerator_mods) |
Parses a string representing an accelerator. More... | |
Glib::ustring | name (guint accelerator_key, Gdk::ModifierType accelerator_mods) |
Converts an accelerator keyval and modifier mask into a string parseable by parse(). More... | |
Glib::ustring | get_label (guint accelerator_key, Gdk::ModifierType accelerator_mods) |
Converts an accelerator keyval and modifier mask into a string which can be used to represent the accelerator to the user. More... | |
Gdk::ModifierType | get_default_mod_mask () |
Gets the modifier mask. More... | |
Detailed Description
Utilities for keyboard accelerators.
We have various utility functions to parse and generate textual representations of keyboard accelerators.
If you want to set up keyboard accelerators for widgets, Gtk::ShortcutTrigger is probably more convenient than the functions in this namespace.
Key values are the codes which are sent whenever a key is pressed or released. The complete list of key values can be found in the gdk/gdkkeysyms.h header file. They are prefixed with GDK_KEY_
.
Function Documentation
Gdk::ModifierType Gtk::Accelerator::get_default_mod_mask | ( | ) |
Gets the modifier mask.
The modifier mask determines which modifiers are considered significant for keyboard accelerators. This includes all keyboard modifiers except for GDK_LOCK_MASK.
- Returns
- The modifier mask for accelerators
Glib::ustring Gtk::Accelerator::get_label | ( | guint | accelerator_key, |
Gdk::ModifierType | accelerator_mods | ||
) |
Converts an accelerator keyval and modifier mask into a string which can be used to represent the accelerator to the user.
- Parameters
-
accelerator_key Accelerator keyval. accelerator_mods Accelerator modifier mask.
- Returns
- A string representing the accelerator.
Glib::ustring Gtk::Accelerator::name | ( | guint | accelerator_key, |
Gdk::ModifierType | accelerator_mods | ||
) |
Converts an accelerator keyval and modifier mask into a string parseable by parse().
For example, if you pass in 'q' and Gdk::ModifierType::CONTROL_MASK, it returns "<Control>q".
If you need to display accelerators in the user interface, see get_label().
- Parameters
-
accelerator_key Accelerator keyval. accelerator_mods Accelerator modifier mask.
- Returns
- The accelerator name.
bool Gtk::Accelerator::parse | ( | const Glib::ustring & | accelerator, |
guint & | accelerator_key, | ||
Gdk::ModifierType& | accelerator_mods | ||
) |
Parses a string representing an accelerator.
The format looks like “<Control>a” or “<Shift><Alt>F1”.
The parser is fairly liberal and allows lower or upper case, and also abbreviations such as “<Ctl>” and “<Ctrl>”. Key names are parsed using gdk_keyval_from_name(). For character keys the name is not the symbol, but the lowercase name, e.g. one would use “<Ctrl>minus” instead of “<Ctrl>-”.
If the parse fails, accelerator_key and accelerator_mods will be set to 0 (zero).
- Parameters
-
accelerator See the Gtk::AccelKey constructor for the format. [out] accelerator_key Accelerator keyval. [out] accelerator_mods Accelerator modifier mask.
- Returns
true
if parsing succeeded.
bool Gtk::Accelerator::valid | ( | guint | keyval, |
Gdk::ModifierType | modifiers | ||
) |
Determines whether a given keyval and modifier mask constitute a valid keyboard accelerator.
For example, the 'a' keyval plus Gdk::ModifierType::CONTROL_MASK is valid - this is a "Ctrl+a" accelerator. But you can't, for instance, use the GDK_KEY_Control_L keyval as an accelerator.
- Returns
true
if the accelerator is valid.