Shiny Language Reference
Language Reference > User Interface > Scrollbars
User Interface Scrollbars
Creating and managing scrollbars
Scrollbars are "helper" controls - they cannot be created and used on their own, they are always used to enhance the features of another control such as a listbox. Scrollbars cannot be individually created, therefore no createscrollbar statement is provided and no control ID is assigned. Scrollbars take the visual appearance of their parent control, such as shading style and background colour.
Scrollbars always operate in the same way, therefore all controls that contain a scrollbar can be manipulated using the commands below. Where a control ID is required for a statement, you must supply the control ID of the parent control. For example, if you want to manipulate the scrollbar in a listbox using setscrollbarpos you should pass the control ID of the listbox (provided by createlistbox) for the first parameter.
The statements below are mainly intended for custom drawn scrollbar usage. When a parent control is set to custom draw the child scrollbar is automatically set to custom draw also. The custom draw handler of the parent control is called with the following states for each element of the scrollbar:
| SSEdit define | Integer value | State to be drawn |
| SCROLLBAR_RANGE | 21 | The scroll range. The scroll thumb and scroll buttons are drawn on top of this image, therefore this should be drawn as the overall height of the scrollbar. |
| SCROLLBAR_UP_NORMAL | 22 | The scroll up button when it is not pressed. |
| SCROLLBAR_DOWN_NORMAL | 23 | The scroll down button when it is not pressed |
| SCROLLBAR_UP_PRESSED | 24 | The scroll up button when it is pressed |
| SCROLLBAR_DOWN_PRESSED | 25 | The scroll down button when it is pressed |
| SCROLLBAR_THUMB | 26 | The scroll thumb. This should be the entire thumb, the segments of the thumb to allow scaling are set using the setscrollbarthumbsegs statement. |
Handler prototype for Scrollbars
Scrollbars do not have an associated event handler function. Any events that must be passed on to the SSE will be done so through the parent control's handler.
setscrollbarpos - Sets the pixel position of the scrollbar within the parent control
setscrollbarsize - Sets the width and height of the scrollbar
setscrollbarthumbsegs - Sets the segment sizes of the scrollbar thumb for a custom drawn control
setscrollbarbuttonheight - Sets the pixel height of the scrollbar up and down scroll buttons