On Fri, Dec 17, 2010 at 4:48 PM, Erik Blankinship <er...@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@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel > > -- Walter Bender Sugar Labs http://www.sugarlabs.org _______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel