Arrow keys as accellerators?



Hi,

I've trying to install accelerator keys for a scrolled window to get the
page-up, page-down, up-arrow and down-arrow keys to act as short-cuts for
the vertical scroll bar. I install them as follows:

    accelGrp = gtk_accel_group_new();
    gtk_window_add_accel_group(GTK_WINDOW(mainWin), accelGrp);
    closure = g_cclosure_new(G_CALLBACK(accelKeyHandler), "up", NULL);
    gtk_accel_group_connect(accelGrp, GDK_uparrow, 0, 0, closure);
    closure = g_cclosure_new(G_CALLBACK(accelKeyHandler), "page-up", NULL);
    gtk_accel_group_connect(accelGrp, GDK_Page_Up, 0, 0, closure);
      ....

This works fine for the page-up and page-down keys, but the up-arrow and
down-arrow keys do not get intercepted and passed to the key handler
function. I'm guessing that this is because they are used for movement
around the buttons on the window. So:

1. Is there some way to unbind the up/down arrow keys from the button
navigation so that they can be used as accelerators?

2. What are the correct GDK key defines for the up/down arrow keys on a
standard PC keyboard: GDK_uparrow/GDK_downarrow, GDK_Up/GDK_Down, or
something else?

3. Is it possible to use gtk_widget_add_accelerator to add accelerators to
the scrollbar, which would be a neater way to do this? If so what are the
signals for page-up, step-up, page-down and step-down?

Thanks,
Ian










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