An xmScrollBar may be horizontal or vertical (depending its -orientation resource). An xmScrollBar is composed of two arrows, a long rectangle called the scroll region, and a smaller rectangle called the slider. The data is scrolled by clicking either arrow, clicking inside the scroll region, or by dragging the slider. When the mouse is held down in the scroll region or in either arrow, the data continues to move at a constant speed.
The following example uses two scrollbars to move a target button:
#! /usr/sgitcl/bin/moat xtAppInitialize xmBulletinBoard .top managed xmScrollBar .top.h managed \ -orientation horizontal -width 150 \ -y 160 -minimum 10 -maximum 140 xmScrollBar .top.v managed \ -orientation vertical -height 150 \ -x 160 -minimum 10 -maximum 140 xmPushButton .top.target managed -labelString "X" proc track_it {} { .top.h getValues -value x .top.v getValues -value y .top.target setValues -x [expr 8+$x] -y [expr 8+$y] } .top.h dragCallback track_it .top.v dragCallback track_it .top.h valueChangedCallback track_it .top.v valueChangedCallback track_it track_it . realizeWidget . mainLoopThe xmScrollBar widget class defines the new resources listed in Table 4-36.
The -value resource specifies the current position of the scrollbar slider, between the minimum and maximum -sliderSize. The slider moves between -minimum and -maximum by -increment steps (clipped at the ends). Clicking either scrollbar arrow moves the slider by -pageIncrement. The -sliderSize reflects the portion of the widget currently in view.
The -troughColor specifies the scrollbar slider fill color. Constant speed movement can be parameterized with -repeatDelay and -initialDelay. If -showArrows is set to False, the scroll bar will not have arrows at either end.
Method Name | Why |
---|---|
decrementCallback | Value was decremented. |
dragCallback | The slider is being dragged. |
incrementCallback | Value was incremented. |
pageDecrementCallback | Value was decremented by pageIncrement. |
pageIncrementCallback | Value was incremented by pageIncrement. |
toTopCallback | Value was reset to minimum. |
toBottomCallback | Value was reset to maximum. |
valueChangedCallback | The value had changed. |
In the callbacks above, the %value substitution returns the current scroll bar position.