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

Walter Bender walter.bender at gmail.com
Fri Dec 17 16:52:45 EST 2010


On Fri, Dec 17, 2010 at 4:48 PM, Erik Blankinship <erikb at mediamods.com> wrote:
> 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?

Maybe I am misunderstanding the complexity of what you are trying to
do... don't you simply check the mode mask when you get a keyboard
event to determine whether or not Alt or Ctrl is pressed?

-walter

>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
>



-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org


More information about the Sugar-devel mailing list