gdkKeymapTranslateKeyboardState    package:RGtk2    R Documentation

_g_d_k_K_e_y_m_a_p_T_r_a_n_s_l_a_t_e_K_e_y_b_o_a_r_d_S_t_a_t_e

_D_e_s_c_r_i_p_t_i_o_n:

     Translates the contents of a 'GdkEventKey' 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 'gdkKeyvalGetKeys()' 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, 'GdkEventKey'
     already contains the translated keyval, so this function isn't as
     useful as you might think.

_U_s_a_g_e:

     gdkKeymapTranslateKeyboardState(object, hardware.keycode, state, group)

_A_r_g_u_m_e_n_t_s:

'object': ['GdkKeymap']  a 'GdkKeymap', or 'NULL' to use the default

'hardware.keycode': [numeric]  a keycode

 'state': ['GdkModifierType']  a modifier state 

 'group': [integer]  active keyboard group

_D_e_t_a_i_l_s:

     *PLEASE 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.


     # We want to ignore irrelevant modifiers like ScrollLock
     all_accels_mask <- GdkModifierType["control-mask"] | 
     GdkModifierType["shift-mask"] | GdkModifierType["mod1-mask"]
     state <- gdkKeymapTranslateKeyboardState(keymap,
     event[["hardware_keycode"]],
                                              event[["state"]],
     event[["group"]])
     unconsumed <- all_accels_mask & event[["state"]] &
     !as.flag(state$consumed) 
     if (state$keyval == .gdkPlus && unconsumed ==
     GdkModifierType["control-mask"])
       print("Control was pressed")
      An older interpretation 'consumed.modifiers' was that it
     contained all modifiers that might affect the translation of the
     key; this allowed accelerators to be stored with irrelevant
     consumed modifiers, by doing:   
     # XXX Don't do this XXX
     unconsumed <- all_accel_mask & event[["state"]] &
     !as.flag(state$consumed)
     if (state$keyval == accel_keyval &&
         unconsumed == accel_mods & !as.flag(state$consumed))
       print("Accellerator was pressed")
      However, this did not work if multi-modifier combinations were
     used in the keymap, since, for instance, '<Control>' would be
     masked out even if only '<Control><Alt>' was used in the keymap.
     To support this usage as well as well as possible, all _single
     modifier_ combinations that could affect the key for any
     combination of modifiers will be returned in 'consumed.modifiers';
     multi-modifier combinations are returned only when actually found
     in 'state'. When you store accelerators, you should always store
     them with consumed modifiers removed. Store '<Control>plus', not
     '<Control><Shift>plus',

_V_a_l_u_e:

     A list containing the following elements: 

  retval: [logical] 'TRUE' if there was a keyval bound to the
          keycode/state/group

'keyval': [numeric]  return location for keyval, or 'NULL'

'effective.group': [integer]  return location for effective group, or
          'NULL'

 'level': [integer]  return location for level, or 'NULL'

'consumed.modifiers': ['GdkModifierType']  return location for
          modifiers that were used to determine the group or level, or
          'NULL'

_N_o_t_e:

     '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.

     An older interpretation 'consumed.modifiers' was that it contained
     all modifiers that might affect the translation of the key; this
     allowed accelerators to be stored with irrelevant consumed
     modifiers, by doing:   However, this did not work if
     multi-modifier combinations were used in the keymap, since, for
     instance, '<Control>' would be masked out even if only
     '<Control><Alt>' was used in the keymap. To support this usage as
     well as well as possible, all _single modifier_ combinations that
     could affect the key for any combination of modifiers will be
     returned in 'consumed.modifiers'; multi-modifier combinations are
     returned only when actually found in 'state'. When you store
     accelerators, you should always store them with consumed modifiers
     removed. Store '<Control>plus', not '<Control><Shift>plus',

_A_u_t_h_o_r(_s):

     Derived by RGtkGen from GTK+ documentation

