[pygtk] Re: problems with ctrl keybindings
Fabian Braennstroem
f.braennstroem at gmx.de
Thu Mar 22 00:32:47 WST 2007
Hi Bryan,
me again ...
Fabian Braennstroem schrieb am 03/17/2007 09:08 PM:
> Hi Bryan,
>
>
> Bryan Feir schrieb am 03/17/2007 08:07 PM:
>> On Sat, Mar 17, 2007 at 06:47:38PM +0000, Fabian Braennstroem wrote:
>>> Hi to both,
>>>
>>> Bryan Feir schrieb am 03/16/2007 02:34 PM:
>>>> 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?
>> Well, then you want to check that 'l' is pressed without CTRL instead:
>>
>> if keyname == "l" and
>> (event.state & gtk.gdk.CONTROL_MASK) == gtk.gdk.CONTROL_MASK:
>> do_control_l()
>> if keyname == "l" and (event.state & gtk.gdk.CONTROL_MASK) == 0:
>> do_l()
>
> thanks, that was pretty easy!
>
now, I know, why it worked before. I used three different
distribution: one at work, which is an old redhat 4.3, the other on
my laptop with a recent kubuntu on it and the a scientific linux
(redhat 4.4 clone) on my desktop. And the problem is that on my
office machine none of the two 'control' combinations work:
if keyname == "l" and
(event.state & gtk.gdk.CONTROL_MASK) == gtk.gdk.CONTROL_MASK:
do_control_l()
if keyname == "l" and (event.state & gtk.gdk.CONTROL_MASK) == 0:
do_l()
They work on my desktop machine with the same 2.4.1 and python 2.5
version as at the office. Strange!?
Do you have any idea, what goes wrong?
Greetings!
Fabian
More information about the pygtk
mailing list