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



 
When using Glade to design a UI, I've noticed that the Button dialog has
an "Activatable/Actionable" section which includes an on/off "Use Action
Appearance" selection. This suggests that you might look into
GtkActionable and kin...

On 2015/03/06 07:55, Jim Charlton wrote:
On 15-03-06 06:52 AM, Michael Torrie wrote:
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?
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Ah.  I see.  Sorry that I misunderstood.  In my case, I just use the
button set_sensitive() method to deactivate the button until I am
ready to reactivate it.  This greys out the button.  I suppose that
you could use this with a short delay to flash the button.  Or you
could just flash the button background color.

It seems like gtk just changes/flashes the background color of the
button when you click it, but I am not sure exactly which method it
uses to do that.

jim...
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

-- 
We're not giving up. We're waiting for a better opportunity to win.
    -- Lois McMaster Bujold


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