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,
would be masked out even if only
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 plus
,
not plus
,