On 15-03-05 07:58 PM, Michael Torrie wrote:
Maybe I'm just not reading right, but I cannot figure out how to make a
GtkButton respond to a single key press. For example, if I made a
simple calculator like the one that comes with Gnome, how can I make it
so when I press '1' on my keyboard, the 1 button presses. I know how to
make shortcuts with a control key by just putting in an & in the label.
But not just a bare key press. Also is it possible to programmatically
depress and then release a GtkButton, simulating a click? I'd like to
do this to generate some user feedback when the keyboard is used, while
allowing one to still click with a mouse (or finger or whatever) on the
GtkButton.
Pointing me at the right docs would be appreciated. Gtk3 is fine.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
I presume you have a callback function connected to the button press
event. Just create code to intercept the keyboard event and go to a
callback function that sees what key was pressed and then calls the same
function that would have been called had the button been pressed.
The first example I found from Google was
http://stackoverflow.com/questions/10134956/in-simple-gtk-key-press-event-example-gdk-shift-mask-seems-to-be-ignored
You can see the code you need to intercept the keyboard event.
I do exactly this sort of thing in programs with the user being able to
hit a select keyboard key or click the button (although I am using gtkmm3).
jim... Jim Charlton
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list