[Sugar-devel] tracking CTRL and ALT keys in a sugar activity

Erik Blankinship erikb at mediamods.com
Fri Dec 17 16:48:07 EST 2010


I would like to know when CTRL or ALT are being pressed in my sugar
activity.  To be complete, I would need to know if they are pressed when the
activity regains focus (e.g. changing activities or if the focus was in a
textfield).

I am not sure of the right way to do this. My current thinking is to keep a
dictionary with CTRL_L, CTRL_R, ALT_L, and ALT_R key states which are
updated on key-press and key-release events.

But this model breaks as soon the application loses focus and the user
releases one of those keys -- I would never know when there is a mouse-up.
My workaround is to clear the dictionary when the application loses focus. I
can also attempt to update the dictionary when there are mouse events by
skimming information from these events regarding CTRL and ALT modifiers.

Is this a good approach? Maybe I am missing something obvious?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101217/ba0ba741/attachment.html>


More information about the Sugar-devel mailing list