maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   How can I get keypress events from virtual keyboard in python? (https://talk.maemo.org/showthread.php?t=45285)

maacruz 2010-02-20 23:56

How can I get keypress events from virtual keyboard in python?
 
I'm porting to the N8x0 a pygtk application which uses keypress events. It works fine with the hardware keyboard, but the virtual keyboard doesn't seem to emit keypress events, except for the enter and backspace keys.
Is there any way to get keypress events when using the virtual keyboard?

noobmonkey 2010-02-21 00:47

Re: How can I get keypress events from virtual keyboard in python?
 
Quote:

Originally Posted by maacruz (Post 539081)
I'm porting to the N8x0 a pygtk application which uses keypress events. It works fine with the hardware keyboard, but the virtual keyboard doesn't seem to emit keypress events, except for the enter and backspace keys.
Is there any way to get keypress events when using the virtual keyboard?

good point... no idea....

Could make your own :) - http://www.ossramblings.com/pygame_virtual_keyboard

daperl 2010-02-21 02:12

Re: How can I get keypress events from virtual keyboard in python?
 
Quote:

Originally Posted by maacruz (Post 539081)
I'm porting to the N8x0 a pygtk application which uses keypress events. It works fine with the hardware keyboard, but the virtual keyboard doesn't seem to emit keypress events, except for the enter and backspace keys.
Is there any way to get keypress events when using the virtual keyboard?

As far as I know, the only way the virtual keyboard will appear in Nokia GTK is if the keyboard focus is grabbed by a widget that implements the gtk.Editable interface, so here are the gtk.Editable signal prototypes:

Code:

"changed"
    def callback(editable, user_param1, ...)

"delete-text"
    def callback(editable, start, end, user_param1, ...)

"insert-text"
    def callback(editable, new_text, new_text_length, position, user_param1, ...)

EDIT: Woops, This seems to only be true for simple text editing, but here's the explaination of "insert-text":

The "insert-text" signal is emitted when text is inserted into the widget by the user. The default handler for this signal will normally be responsible for inserting the text, so by connecting to this signal and then stopping the signal with the gobject.stop_emission() method, it is possible to prevent it from being inserted entirely. The position parameter is a gobject.GPointer object containing a pointer to the insertion position - there is no way to access the position value from PyGTK.

maacruz 2010-02-21 22:29

Re: How can I get keypress events from virtual keyboard in python?
 
Yes, it seems the only way is to override the do_insert_text method from the gtk.Editable interface. For now, I settled to using the TAB key (the event of interest was triggered by the space key).
Now, another question: How can I set the taskbar icon?
No matter how much I try, it seems I can't do it. I have copied the icon to /usr/share/pixmaps and /usr/share/icons/hicolor/26x26/hildon, updated the icon cache, and created a .desktop file. The icon shows in the menu, but not in the taskbar. gtk.window_set_default_icon() doesn't seem to work.

qwerty12 2010-02-21 22:40

Re: How can I get keypress events from virtual keyboard in python?
 
Quote:

Originally Posted by maacruz (Post 540200)
Now, another question: How can I set the taskbar icon?
No matter how much I try, it seems I can't do it. I have copied the icon to /usr/share/pixmaps and /usr/share/icons/hicolor/26x26/hildon, updated the icon cache, and created a .desktop file. The icon shows in the menu, but not in the taskbar. gtk.window_set_default_icon() doesn't seem to work.

Don't bother with the GTK+ functions for setting the icon; hildon-desktop only takes notice if the icon is 64x54 (thanks, javispedro) and you shouldn't need them.
It's been a looong time since I've dealt with icon issues on the N8x0 (Fremantle is nicer in this regard, with the menu icon being the only thing you have to worry about :)) so all I can offer is general hints (sorry if these come off as "No ****, Sherlock").

* The icon in /usr/share/icons/hicolor/26x26/hildon is a 26x26 PNG, with the same file name as the the one in /usr/share/pixmaps etc.?
* You have a 64x64 PNG in /usr/share/icons/hicolor/scalable/hildon?
* In your desktop file, you aren't trying to set the icon directory or the WMClass?
* Hildon-desktop takes notice of the X-Window-Icon and X-Window-Icon-Dimmed fields in the desktop file if all else fails.

maacruz 2010-02-21 22:55

Re: How can I get keypress events from virtual keyboard in python?
 
Thanks, after much renaming and linking I finally got it (the png file has to have the same name as the executable), but your hints will allow me to do it right once and for all :)

qwerty12 2010-02-21 22:58

Re: How can I get keypress events from virtual keyboard in python?
 
Quote:

Originally Posted by maacruz (Post 540235)
Thanks, after much renaming and linking I finally got it (the png file has to have the same name as the executable), but your hints will allow me to do it right once and for all :)

Makes sense... Hildon-desktop is very pedantic about WMClass (esp. in regard to icons) and I believe GDK sets the WMClass for a GTK+ app from argv[0] :)


All times are GMT. The time now is 06:42.

vBulletin® Version 3.8.8