Re: Detecting Ctrl Esc in GTK app



How would you link it directly to the window then rather than to a widget?

As far as I can see you need to associate it with a signal, but looking down the list of signals for windows I cant really see one suitable, hence I was using this:

gtk_widget_add_accelerator(quitbutton,"clicked",accelgroup,GDK_Q,GDK_CONTROL_MASK,GTK_ACCEL_LOCKED);
g_signal_connect(G_OBJECT(quitbutton),"clicked",G_CALLBACK(handleControlQ),NULL);

Im using Ctrl Q for the time being as I havent worked out how to set it up for Esc yet.

The reason for doing this is Im writing an app for a public kiosk which will take over the whole screen and not provide any way for the user to exit the app. The admin will press Ctrl Esc (or Ctrl Q for the moment) which will pop up a dialog for a password to exit the app.

On 30/08/11 14:19, jcupitt gmail com wrote:
Hi Andrew,

You can add an accelerator to a window and it'll be called when that
key combination is pressed. It doesn't need to be associated with a
widget.

However I think it's generally considered good form to have a menu
item somewhere with the accelerator as a shortcut. That way the user
can discover your handy keypress and get some idea what it does.

John

On 30 August 2011 14:03, Andrew Wood<a j w me com>  wrote:
Thanks for the tip.  Can accelerators only be used with menu items, only Ive
just tried doing it by linking it to the clicked signal on a (hidden)
GtkButton but it doesnt work?

My idea was when the key combo was pressed the accelerator would emit a
clicked signal on the button and the buttons handler would then be called.

On 30/08/11 09:52, jcupitt gmail com wrote:
That lets you detect ctrl-esc anywhere on the desktop. If you only
need to detect crtl-ecs within your window you can just set
"<Control>Escape" as an accelerator, see:

http://developer.gnome.org/gtk3/stable/gtk3-Keyboard-Accelerators.html

On 30 August 2011 06:33, czk<czongke gmail com>    wrote:
try gdk_window_add_filter or gtk_key_snooper_install

2011/8/30 Andrew Wood<a j w me com>

Is there a way to regiser a handler function which will be called
whenever
the user presses Ctrl-Esc in a GTK app?

Thanks

______________________________**_________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

http://mail.gnome.org/mailman/**listinfo/gtk-app-devel-list<http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list>

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

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





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