GTK+ 1.2 Tutorial
Prev | Chapter 8. Range Widgets | Next

# Key and Mouse bindings

All of the GTK range widgets react to mouse clicks in more or less the same way. Clicking button-1 in the trough will cause its adjustment's `page_increment` to be added or subtracted from its `value`, and the slider to be moved accordingly. Clicking mouse button-2 in the trough will jump the slider to the point at which the button was clicked. Clicking any button on a scrollbar's arrows will cause its adjustment's value to change `step_increment` at a time.

It may take a little while to get used to, but by default, scrollbars as well as scale widgets can take the keyboard focus in GTK. If you think your users will find this too confusing, you can always disable this by unsetting the `GTK_CAN_FOCUS` flag on the scrollbar, like this:

    GTK_WIDGET_UNSET_FLAGS (scrollbar, GTK_CAN_FOCUS);

The key bindings (which are, of course, only active when the widget has focus) are slightly different between horizontal and vertical range widgets, for obvious reasons. They are also not quite the same for scale widgets as they are for scrollbars, for somewhat less obvious reasons (possibly to avoid confusion between the keys for horizontal and vertical scrollbars in scrolled windows, where both operate on the same area).

## Vertical Range Widgets

All vertical range widgets can be operated with the up and down arrow keys, as well as with the `Page Up` and `Page Down` keys. The arrows move the slider up and down by `step_increment`, while `Page Up` and `Page Down` move it by `page_increment`.

The user can also move the slider all the way to one end or the other of the trough using the keyboard. With the VScale widget, this is done with the `Home` and `End` keys, whereas with the VScrollbar widget, this is done by typing `Control-Page Up` and `Control-Page Down`.

## Horizontal Range Widgets

The left and right arrow keys work as you might expect in these widgets, moving the slider back and forth by `step_increment`. The `Home` and `End` keys move the slider to the ends of the trough. For the HScale widget, moving the slider by `page_increment` is accomplished with `Control-Left` and `Control-Right`, while for HScrollbar, it's done with `Control-Home` and `Control-End`.

Prev | Home | Next
Common Range Functions | Up | Example