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

2015-03-06 Thread Michael Torrie
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


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

2015-03-06 Thread Jim Charlton

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


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

2015-03-06 Thread Michael Cronenworth

On 03/06/2015 08:52 AM, Michael Torrie wrote:

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?


You can call g_signal_emit_by_name() for the GtkButton activate signal to get the 
visual animation of a button press and release.

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2015-03-06 Thread Phil Wolff
 
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
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2015-03-06 Thread Michael Torrie
On 03/06/2015 08:23 AM, Michael Cronenworth wrote:
 On 03/06/2015 08:52 AM, Michael Torrie wrote:
 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?
 
 You can call g_signal_emit_by_name() for the GtkButton activate signal to 
 get the 
 visual animation of a button press and release.

Ahh. Yes this is what I want mostly. Is there any way to get it to
animate down and hold there, say when a person is holding down the key?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2015-03-05 Thread Jim Charlton

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