[pygtk] Re: problems with ctrl keybindings
Fabian Braennstroem
f.braennstroem at gmx.de
Sun Mar 18 03:47:38 WST 2007
Hi to both,
Bryan Feir schrieb am 03/16/2007 02:34 PM:
> On Fri, Mar 16, 2007 at 08:54:28AM +0100, Thomas Guettler wrote:
>> Am Donnerstag, 15. M?rz 2007 18:34 schrieb Fabian Braennstroem:
>>> Hi,
>>>
>>> I have some own keybindings for my filemanager, which work pretty
>>> well. Except combinations with the 'Control' key make problems (but
>>> if (keyname == "l" and event.state == gtk.gdk.CONTROL_MASK):
>>> 'do_something'
>> Hi,
>>
>> I guess yo need to use & instead of ==
>
> Yes. Specifically the problem is that if you use '==', then the
> match won't work if you have any other modifier keys active, including
> NumLock. Which could be why it seemed to work before but not now. So
> you need to check only those state bits that you require. If you need
> to match Control but not Shift, for example, then it would be something
> like:
> (event.state & (gtk.gdk.CONTROL_MASK|gtk.gdk.SHIFT_MASK)) ==
> gtk.gdk.CONTROLMASK
thanks for your advice, but I did not tell you everything... I am
able to catch the 'control' key, but when I have an additional
binding just e.g. for 'l' like:
if keyname == "l":
both bindings get 'activated', when pressing 'Ctrl+l'. Do you have
any idea to correct this?
Greetings!
Fabian
More information about the pygtk
mailing list