SCROLLBARENABLEname
state
Enables or disables the scrollbar identified by name
.
If state
equals TRUE, then the scrollbar is enabled.
If state
equals FALSE, then the scrollbar is disabled.
When a scrollbar is disabled, the position of the scrollbar is hidden. If you want the user to be able to see the position of a scrollbar, but not be able to change it, then use an enabled scrollbar and make the scrollbar's callback reset the position back to the correct value. This pattern is shown in the second example, below.
Disabling a scrollbar:
WINDOWCREATE "main "mywindow "mytitle 0 0 100 100 [] SCROLLBARCREATE "mywindow "myscroll 25 25 50 0 [] SCROLLBARENABLE "myscroll "False
The scrollbar is now disabled.
SCROLLBARENABLE "myscroll "True WINDOWDELETE "mywindow
Creating a read-only scrollbar:
TO SCROLLBARCALLBACK ; Whenever the user changes the scrollbar's position, ; change it back to the correct value, which is held ; in :ScrollbarValue. ; ; In order to avoid an infinite loop, only change the ; value if it's different from what we would set it to. IF NOT EQUALP :ScrollbarValue SCROLLBARGET "myscroll [ SCROLLBARSET "myscroll 0 360 :ScrollbarValue ] END TO SCROLLBARUPDATE :NewValue ; Call this whenever you want to update the value. MAKE "ScrollbarValue :NewValue SCROLLBARCALLBACK END ; Create a window with a read-only scrollbar. WINDOWCREATE "main "mywindow [Read Only Scrollbar Example] 0 0 100 30 [] SCROLLBARCREATE "mywindow "myscroll 5 5 90 0 [ SCROLLBARCALLBACK ] ; Set initial value. SCROLLBARUPDATE 50
Try to change the scrollbar's position with the mouse. It snaps back to the value which is set by SCROLLBARUPDATE in SCROLLBARCALLBACK.
; Programmatically change the value. SCROLLBARUPDATE 100 ; Delete the window when you're done. WINDOWDELETE "mywindow