Libraries:Gtk:Gdk:Keymap
Types
T
Inherits from:Constants
Nil : T
Functions
GetDefault() : Gtk.Gdk.Keymap.T
GetForDisplay(display @ Gtk.Gdk.Display.T) : Gtk.Gdk.Keymap.T
Returns the T attached to display.
display | the Gtk.Gdk.Display.T. |
Returns | the T attached to display. |
GetType() : Gtk.GObject.Type.T
Methods
:AddVirtualModifiers(self @ T, state @ Std.Object.T) : Std.Object.T
Adds virtual modifiers (i.e. Super, Hyper and Meta) which correspond to the real modifiers (i.e Mod2, Mod3, ...) in modifiers. are set in state to their non-virtual counterparts (i.e. Mod2, Mod3,...) and set the corresponding bits in state.
GDK already does this before delivering key events, but for compatibility reasons, it only sets the first virtual modifier it finds, whereas this function sets all matching virtual modifiers.
This function is useful when matching key events against accelerators.
keymap | a T |
state | pointer to the modifier mask to change |
:GetCapsLockState(self @ T) : Std.Symbol.T
:GetDirection(self @ T) : Gtk.Pango.Direction.T
Returns the direction of effective layout of the keymap.
Note that passing NULL for keymap is deprecated and will stop to work in GTK+ 3.0. Use GetForDisplay instead.
Returns the direction of the keymap.
keymap | a T or NULL to use the default keymap |
Returns | Gtk.Pango.Direction.Ltr or Gtk.Pango.Direction.Rtl if it can determine the direction. Gtk.Pango.Direction.Neutral otherwise. |
:GetEntriesForKeycode(self @ T, hardware_keycode @ Std.Integer.SmallT, keys @ Std.Object.T, keyvals @ Std.Object.T, n_entries @ Std.Object.T) : Std.Symbol.T
Returns the keyvals bound to hardware_keycode. The Nth Gtk.Gdk.KeymapKey.T in keys is bound to the Nth keyval in keyvals. Free the returned arrays with g_free(). When a keycode is pressed by the user, the keyval from this list of entries is selected by considering the effective keyboard group and level. See TranslateKeyboardState.
keymap | a T or NULL to use the default keymap |
hardware_keycode | a keycode |
keys | return location for array of Gtk.Gdk.KeymapKey.T, or NULL |
keyvals | return location for array of keyvals, or NULL |
n_entries | length of keys and keyvals |
Returns | TRUE if there were any entries |
:GetEntriesForKeyval(self @ T, keyval @ Std.Integer.SmallT, keys @ Std.Object.T, n_keys @ Std.Object.T) : Std.Symbol.T
Obtains a list of keycode/group/level combinations that will generate keyval. Groups and levels are two kinds of keyboard mode; in general, the level determines whether the top or bottom symbol on a key is used, and the group determines whether the left or right symbol is used. On US keyboards, the shift key changes the keyboard level, and there are no groups. A group switch key might convert a keyboard between Hebrew to English modes, for example. Gtk.Gdk.EventKey.T contains a group field that indicates the active keyboard group. The level is computed from the modifier mask. The returned array should be freed with g_free().
keymap | a T, or NULL to use the default keymap |
keyval | a keyval, such as GDK_a, GDK_Up, GDK_Return, etc. |
keys | return location for an array of Gtk.Gdk.KeymapKey.T |
n_keys | return location for number of elements in returned array |
Returns | TRUE if keys were found and returned |
:HaveBidiLayouts(self @ T) : Std.Symbol.T
Determines if keyboard layouts for both right-to-left and left-to-right languages are in use.
Note that passing NULL for keymap is deprecated and will stop to work in GTK+ 3.0. Use GetForDisplay instead.
keymap | a T or NULL to use the default keymap |
Returns | TRUE if there are layouts in both directions, FALSE otherwise |
:LookupKey(self @ T, key @ Gtk.Gdk.KeymapKey.T) : Std.Integer.SmallT
Looks up the keyval mapped to a keycode/group/level triplet. If no keyval is bound to key, returns 0. For normal user input, you want to use TranslateKeyboardState instead of this function, since the effective group/level may not be the same as the current keyboard state.
keymap | a T or NULL to use the default keymap |
key | a Gtk.Gdk.KeymapKey.T with keycode, group, and level initialized |
Returns | a keyval, or 0 if none was mapped to the given key |
:MapVirtualModifiers(self @ T, state @ Std.Object.T) : Std.Symbol.T
Maps the virtual modifiers (i.e. Super, Hyper and Meta) which are set in state to their non-virtual counterparts (i.e. Mod2, Mod3,...) and set the corresponding bits in state.
This function is useful when matching key events against accelerators.
keymap | a T |
state | pointer to the modifier state to map |
Returns | TRUE if no virtual modifiers were mapped to the same non-virtual modifier. Note that FALSE is also returned if a virtual modifier is mapped to a non-virtual modifier that was already set in state. |
:TranslateKeyboardState(self @ T, hardware_keycode @ Std.Integer.SmallT, state @ Std.Integer.SmallT, group @ Std.Integer.SmallT, keyval @ Std.Object.T, effective_group @ Std.Object.T, level @ Std.Object.T, consumed_modifiers @ Std.Object.T) : Std.Symbol.T
Translates the contents of a Gtk.Gdk.EventKey.T into a keyval, effective group, and level. Modifiers that affected the translation and are thus unavailable for application use are returned in consumed_modifiers. See the section called "Description" for an explanation of groups and levels. The effective_group is the group that was actually used for the translation; some keys such as Enter are not affected by the active keyboard group. The level is derived from state. For convenience, Gtk.Gdk.EventKey.T already contains the translated keyval, so this function isn't as useful as you might think.
Note
consumed_modifiers gives modifiers that should be masked out from state when comparing this key press to a hot key. For instance, on a US keyboard, the plus symbol is shifted, so when comparing a key press to a <Control>plus accelerator <Shift> should be masked out.
1 2 3 4 5 6 7 8 |
/* We want to ignore irrelevant modifiers like ScrollLock */ #define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK) gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode, event->state, event->group, &keyval, NULL, NULL, &consumed); if (keyval == GDK_PLUS && (event->state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK) /* Control was pressed */ |