如何在Mac OS X上检测GTK中的alt / option键是否关闭?

时间:2021-11-24 16:49:01

I want to detect whether the alt/option key is pressed during a mouse drag in GTK on Mac OS X. I am using pygtk. Normally, holding down alt would add MOD1_MASK to event.state, but alt does affect event.state at all. In key press events alt shows up as gtk.keysyms.kana_switch, but this is not sufficient for my purposes since the user might press alt in a different application and switch to mine by clicking.

我想检测在Mac OS X上的GTK鼠标拖动过程中是否按下了alt /选项键。我正在使用pygtk。通常,按住alt会将MOD1_MASK添加到event.state,但alt确实会影响event.state。在按键事件中,alt显示为gtk.keysyms.kana_switch,但这不足以满足我的目的,因为用户可能会在其他应用程序中按alt并通过单击切换到我的。

Is there an available setting that would cause alt/option to show up as a modifier in event.state? Alternatively, is there a way of detecting whether a key is currently down even if the key down event went to a different application?

是否有可用的设置会导致alt / option在event.state中显示为修饰符?或者,是否有一种方法可以检测密钥当前是否已关闭,即使按键事件发生在另一个应用程序中?

1 个解决方案

#1


0  

I think you should use gtk.accelerator_get_default_mod_mask()
http://library.gnome.org/devel/gtk/unstable/checklist-modifiers.html

我认为你应该使用gtk.accelerator_get_default_mod_mask()http://library.gnome.org/devel/gtk/unstable/checklist-modifiers.html

#1


0  

I think you should use gtk.accelerator_get_default_mod_mask()
http://library.gnome.org/devel/gtk/unstable/checklist-modifiers.html

我认为你应该使用gtk.accelerator_get_default_mod_mask()http://library.gnome.org/devel/gtk/unstable/checklist-modifiers.html