Thanks, that's gotten me on the right track now.

Neil

On 18 October 2011 17:04, Dong Luo <us...@yahoo.com> wrote:

> Please check references for gtk and gdk. I just did that and came with a
> simple example showing the keyBindings. Please note that it's not tested as
> I currently don't have gtk installed on my machine.
>
> static gboolean keyBindings( GtkWidget *widget,
>                               GdkEvent  *event,
>                               gpointer   data )
> {
>     GtkWidget *popup;
>
>     if (event->type != GDK_KEY_PRESS) return FALSE;
>
>     // here crtl-x will popup a new window
>     if (((GdkEventKey)event->keyval == GDK_x) &&
>         ((GdkEventKey)event->state & GDK_CONTROL_MASK)) {
>         popup = gtk_window_new(GTK_WINDOW_POPUP);
>         gtk_widget_show (window);
>     }
>     // more keyBindings can be checked
>
>     return TRUE;
> }
>
> int main( int   argc,
>           char *argv[] )
> {
>     GtkWidget *window;
>
>     gtk_init (&argc, &argv);
>
>     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>
>     g_signal_connect (window, "key_press_event", G_CALLBACK (keyBindings),
> NULL);
>
>     gtk_widget_show (window);
>     gtk_main();
>     return 0;
> }
>
> Dong
>
> ------------------------------
> *From:* Neil Munro <neilmu...@gmail.com>
> *To:* gtk-app-devel-list@gnome.org
> *Sent:* Monday, October 17, 2011 11:43 AM
> *Subject:* Re: Keybindings
>
>
>
> On 17 October 2011 15:54, Dong Luo <us...@yahoo.com> wrote:
>
> Hi,
>
> I did not use gtk recently. But I figure you can just let the toplevel
> widget response to the signal of key-press-event and do what ever
> Keybindings you want there.
>
> Dong
>
>
> Could you show me an example as I have figured out the key-press-event is
> the key here, but I can't seem to figure it out yet. Do I set up a
> signal_connect from the window or something?
>
>
>
> ------------------------------
> *From:* Neil Munro <neilmu...@gmail.com>
> *To:* gtk-app-devel-list@gnome.org
> *Sent:* Sunday, October 16, 2011 6:55 AM
> *Subject:* Keybindings
>
> Hi all
>       I want to simply press a keybinding and run a function that shows
> hidden widgets is this possible and if so, how? It strikes me as something
> not too difficult, but I am a self taught C programmer so I may simply not
> know what such a thing would be called. I have already used an accelerator
> group to work with widgets on screen, but what I want to do here has no
> widget to click or whatever to show these.
>
> Thanks,
> Neil Munro
> _______________________________________________
> 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

Reply via email to