Re: How to make a GtkButton respond to a key press



On 03/05/2015 09:31 PM, Jim Charlton wrote:
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).

No, this is not quite what I am asking for.  Capturing keyboard events
is fine, but I need the button to click visually, for feedback purposes.
 Just like what happens if you define the control key shortcut and press
that.

So the question is either, how can I get GtkButton to respond to a
non-modifier hotkey, or how can I programmatically get GtkButton to
visually depress and release?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]