3
votes

I stumbled upon an interesting behavior in the Trackbar Winforms control.

On a horizontal trackbar, the left/right arrow keys work as expected. (Left arrow moves the slider to the left and decreases the value, right arrow does the opposite) It is also possible to manipulate the slider using the up/down arrow keys and PageUp/PageDown. However, the behavior seem counter-intuitive: arrow up and page up move the slider to the left and consequently decrease the value. Arrow down and page down move the slider to the right and increase the value.

When using a vertical trackbar, up/down keys work as expected but arrow left = increase and arrow right = decrease.

This is the default behavior in C# Winforms, and apparently in native Windows. (Not sure about the latter, the slider for UAC does work this way)

In WPF the slider control works "properly" i.e. the value increases with arrow up, arrow right und PgUp. Also the slider in Internet Explorer Privacy settings works properly. Not sure why, but I suspect a custom handling of the keys.

From an ergonomics standpoint, it is clear that up, right, forward and clockwise manipulation of anything is supposed to increase the value. (This nothing new, compare A Guide to Human Factors and Ergonomics, Second Edition Page 100 )

Now to my Question: Does anyone know why this is the way it is?

1

1 Answers

1
votes

I'm strongly inclined to think this behavior was chosen to keep the trackbar control consistent with the scrollbar control.

These two controls have very much in common (their thumb can be moved by "line" or "page" increments, both controls can be laid out horizontally or vertically, both use WM_HSCROLL and WM_VSCROLL to notify their parent when the thumb position changes).

From the control's point of view, the thumb can move "up" or "down" ("left" or "right" respectively). The keyboard navigation for scrollbars used Left and Up for upwards (leftwards) movement, as well as Right and Down for downwards (rightwards) movement.

It must have made sense for the trackbar control to follow the same conventions, so developers used to the scrollbar control's implementation could apply the same principles to the trackbar control.