Oops, sorry I didn't reply earlier... Lots of work. ;)
On 20-Jun-2000 James Henstridge wrote:
> On Tue, 20 Jun 2000, Bellamy Bruno wrote:
>> I'm trying to catch the key_release event in a GtkText, so I had to
>> use a mygtktext.add_events(GDK.KEY_RELEASE_MASK).
>> But it seems to work only after I start by clicking in
>> the GtkText with the mouse. Otherwise, no key_release event is detected.
>
> The widget will only receive key press events if it has focus. That could
> be what the problem you are seeing. Does the problem go away if you call
> text_widget.grab_focus() ?
I do call mygtktext.grab_focus() and it doesn't make any difference.
I can type text, but I cannot catch the key-release event.
On 20-Jun-2000 Matt Wilson wrote:
> Add:
> mygthtext.set_events (KEY_RELEASE_MASK)
Doesn't make any difference either... Sigh.
So, I'm really stuck with this, because I need to check the key_release event
and one of the main interests in my project is that it wouldn't need any mouse
action...
Should I generate a fake mouse click? But I just don't know at all the syntax
for this (and I wonder if it's a good way to solve the problem).
Here's a little source script to show the problem (it's supposed to display
'Press' and 'Release' following the events... But 'Release' never happens
unless there has been a mouse click in the window):
#!/usr/bin/env python
from gtk import *
def keypress(widget, event):
texte.insert(None, None, None, 'Press\n')
def keyrelease(widget, event):
texte.insert(None, None, None, 'Release\n')
def destroy(args):
fenetre.destroy(); mainquit()
fenetre = GtkWindow()
fenetre.connect('destroy', destroy)
texte = GtkText(None, None)
texte.add_events(GDK.KEY_RELEASE_MASK)
texte.set_events(GDK.KEY_RELEASE_MASK)
texte.connect('key_press_event', keypress)
texte.connect('key_release_event', keyrelease)
fenetre.add(texte)
texte.grab_focus()
fenetre.show_all()
mainloop()
----------------------------------
E-Mail: Bellamy Bruno <[EMAIL PROTECTED]>
Date: 01-Jul-2000
Time: 13:32:26
This message was sent by XFMail
----------------------------------
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk