On Fri, Dec 17, 2010 at 05:23:03PM -0500, Erik Blankinship wrote: > On Fri, Dec 17, 2010 at 4:52 PM, Walter Bender <walter.ben...@gmail.com>wrote: > > > 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... > > > I want to change my cursor into a magicwand whenever CTRL or ALT are held > down, and when none of them are pressed, I want to change my cursor into the > system pointer. I do not want someone to cheat by switching out of the > activity with CTRL down and return with my activity thinking CTRL is still > down.
You can use key-press-event event http://library.gnome.org/devel/gtk/stable/GtkWidget.html#GtkWidget-key-press-event see event.state to check what modifier was pressed http://library.gnome.org/devel/gdk/stable/gdk-Event-Structures.html#GdkEventKey > don't you simply check the mode mask when you get a keyboard > > event to determine whether or not Alt or Ctrl is pressed? > > > > Thank you! Yes, I can do that while the activity is running. That sure > makes things simpler while the activity has focus. > > But to determine if CTRL or ALT are pressed when returning to the activity? > I am not sure what signal to listen to that would have the correct mode > mask. > _______________________________________________ > Sugar-devel mailing list > Sugar-devel@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel -- Aleksey _______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel