Difference between revisions of "Scrollbar"

From Xojo Documentation

m (1 revision)
 
 
(22 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 +
{{DeprecatedItem|version=2021r3|replacement=[[DesktopScrollbar]]}}
 +
{{ClassBox
 +
| super=[[RectControl]]
 +
| platform=all
 +
| scope=global
 +
}}
 +
{{Description
 +
| text=The scrollbar control.
 +
}}
  
 +
<dynamicTable id="Events" super="RectControl" class="eventTable" title="Events" columns="3">
 +
{{Event | name=GotFocus | description=GotFocus()&#x0A;The scrollbar has received the focus (Windows and Linux). }}
 +
{{Event | name=LostFocus | description=LostFocus()&#x0A;The scrollbar has lost the focus (Windows and Linux). }}
 +
{{Event | name=MouseDown | params=x as [[Integer]],y as [[Integer]] | returntype=[[Boolean]] | description=MouseDown(x as Integer,y as Integer) as Boolean&#x0A;The mouse button was pressed inside the scrollbar at the location passed in to x,y }}
 +
{{Event | name=MouseDrag | params=x as [[Integer]], y as [[Integer]] | description=MouseDrag(x as Integer, y as Integer)&#x0A;The mouse button was pressed inside the Scrollbar and moved (dragged) at the location local to the control passed in to x,y }}
 +
{{Event | name=MouseUp | params=x as [[Integer]], y as [[Integer]] | description=MouseUp(x as Integer, y as Integer)&#x0A;The mouse button was released inside the scrollbar at the location passed in to x,y.  }}
 +
{{Event | name=ValueChanged | description=ValueChanged()&#x0A;The scrollbar value has changed. }}
 +
</dynamicTable>
  
=='''Description'''==
 
The scrollbar control.
 
  
 +
<dynamicTable id="Properties" super="RectControl" class="propertyTable" title="Properties" columns="3">
 +
{{Property | name=AllowFocus | type=Boolean | platform=all | description=( Boolean)&nbsp;&nbsp;If True, the Scrollbar can accept the focus. The default is False. }}
 +
{{Property | name=AllowLiveScrolling | type=Boolean | platform=all | readonly=no | description=( Boolean)&nbsp;&nbsp;If True, a ValueChanged event occurs as the user drags the thumbnail in the scrollbar. }}
 +
{{Property | name=LineStep | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;The amount the value changes when a scroll arrow is clicked. The default is 1. }}
 +
{{Property | name=MaximumValue | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;The maximum value of the scrollbar. The default is 100.  }}
 +
{{Property | name=MinimumValue | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;The minimum value of the scrollbar. The default is 0. }}
 +
{{Property | name=PageStep | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;The amount the value changes when the user clicks in the Scrollbar track. }}
 +
{{Property | name=Value | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;The current value of the scrollbar. }}
 +
</dynamicTable>
  
  
=='''Super Class'''==
+
<dynamicTable id="Methods" super="RectControl" class="methodTable" title="Methods" columns="3">
[[RectControl|RectControl]]
+
</dynamicTable>
  
Because this is a [[RectControl|RectControl]], see the [[RectControl|RectControl]] for other properties and events that are common to all [[RectControl|RectControl]] objects.
+
==Notes==
 
 
 
 
 
 
=='''Events'''==
 
 
 
{| cellpadding="8" cellspacing="0" border="1"
 
 
 
! width=10%  style="background-color:#e0e0e0" | Name
 
 
 
! width=20%  style="background-color:#e0e0e0" | Parameters
 
 
 
! width=25%  style="background-color:#e0e0e0" | Return Type
 
 
 
! width=55%  style="background-color:#e0e0e0" | Description
 
|-
 
|GotFocus
 
 
 
|
 
|
 
|The scrollbar has received the focus (Windows and Linux).
 
On Linux, the scrollbar is not in the tab order but it gets the focus when the user clicks on it. Scrollbars do not get the focus on Macintosh even when the user is manipulating them.
 
 
 
|-
 
|LostFocus
 
 
 
|
 
|
 
|The scrollbar has lost the focus (Windows and Linux).
 
 
 
|-
 
|MouseDown
 
 
 
|x as [[Integer|Integer]],
 
y as [[Integer|Integer]]
 
|[[Boolean|Boolean]]
 
|The mouse button was pressed inside the scrollbar at the location passed in to x,y. Returns a [[Boolean|Boolean]].
 
[[Return|Return]] [[True|True]] if you are going to handle the MouseDown. The coordinates x, and y are local to the control. Point 0,0 is the top-left corner of the entire control.
 
 
 
|-
 
|MouseDrag
 
 
 
|x as [[Integer|Integer]],
 
y as [[Integer|Integer]]
 
|
 
|The mouse button was pressed inside the Scrollbar and moved (dragged) at the location local to the control passed in to x,y.
 
This event will not occur unless you return [[True|True]] in the MouseDown event.
 
 
 
|-
 
|MouseUp
 
 
 
|x as [[Integer|Integer]],
 
y as [[Integer|Integer]]
 
|
 
|The mouse button was released inside the scrollbar at the location passed in to x,y.
 
This event will not occur unless you return [[True|True]] in the MouseDown event.
 
 
 
|-
 
|ValueChanged
 
 
 
|
 
|
 
|The scrollbar value has changed.
 
 
 
|-
 
|}
 
 
 
 
 
=='''Properties'''==
 
 
 
{| cellpadding="8" cellspacing="0" border="1"
 
 
 
! width=10%  style="background-color:#e0e0e0" | Name
 
 
 
! width=15%  style="background-color:#e0e0e0" | Type
 
 
 
! width=55%  style="background-color:#e0e0e0" | Description
 
|-
 
|AcceptFocus
 
<div style="font-style:italic; color:green;">Introduced 2005r1</div>
 
|[[Boolean|Boolean]]
 
|If [[True|True]], the Scrollbar can accept the focus. The default is [[False|False]].
 
This property is Windows-only. When the Scrollbar has the focus, the user can change its value with the arrow keys. Up and Left lower the value and Right and Down increase the value.
 
 
 
|-
 
|LineStep
 
 
 
|[[Integer|Integer]]
 
|The amount the value changes when a scroll arrow is clicked. The default is 1.
 
 
 
|-
 
|<div style="font-weight:bold; color:red;">LiveScroll</div>
 
|[[Boolean|Boolean]]
 
|If [[True|True]], a ValueChanged event occurs as the user drags the thumbnail in the scrollbar. Otherwise, a single ValueChanged event occurs when the user stops dragging the thumbnail.
 
 
 
|-
 
|Maximum
 
 
 
|[[Integer|Integer]]
 
|The maximum value of the scrollbar. The default is 100.
 
 
 
|-
 
|Minimum
 
 
 
|[[Integer|Integer]]
 
|The minimum value of the scrollbar. The default is 0.
 
 
 
|-
 
|PageStep
 
 
 
|[[Integer|Integer]]
 
|The amount the value changes when the user clicks in the Scrollbar track.
 
 
 
|-
 
|Value
 
 
 
|[[Integer|Integer]]
 
|The current value of the scrollbar.
 
 
 
|-
 
|}
 
 
 
 
 
=='''Notes'''==
 
 
A '''Scrollbar''' can be either horizontal or vertical. To set its orientation programatically, set the height to be greater than the width for a vertical scrollbar. Set the width to be greater than the height for a horizontal scrollbar. The default thickness of the short side is 16 pixels, but it can be changed. You can narrow it in the IDE to get a mini-scrollbar.
 
A '''Scrollbar''' can be either horizontal or vertical. To set its orientation programatically, set the height to be greater than the width for a vertical scrollbar. Set the width to be greater than the height for a horizontal scrollbar. The default thickness of the short side is 16 pixels, but it can be changed. You can narrow it in the IDE to get a mini-scrollbar.
  
 
+
==Examples==
 
 
=='''Examples'''==
 
 
Changing the maximum value of a '''Scrollbar''' at runtime:
 
Changing the maximum value of a '''Scrollbar''' at runtime:
{| cellpadding="8" cellspacing="0" border="1"
 
|<div style="width:100%; background-color:#d0d0d0; padding-left:30px">ScrollBar1.maximum=200
 
<br /></div>
 
 
|-
 
|}
 
 
Setting the text of a [[StaticText|StaticText]] control to the value of the '''Scrollbar''' when the user scrolls:
 
{| cellpadding="8" cellspacing="0" border="1"
 
|<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[Sub|Sub]] ValueChanged()
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[StaticText|staticText1]].text=[[Str|Str]](scrollbar1.value)
 
<br /></div>
 
 
|-
 
|}
 
  
See also the discussion of scrolling [[ListBox|ListBox]] controls horizontally using a '''Scrollbar''' control.
+
<rbcode>
 +
Scrollbar1.MaximumValue = 200
 +
</rbcode>
  
 +
Setting the text of a [[Label]], control to the value of the '''Scrollbar''' when the user scrolls:
  
 +
<rbcode>
 +
Sub ValueChanged()
 +
  Label1.Value = Str(Scrollbar1.Value)
 +
End Sub
 +
</rbcode>
  
=='''See Also'''==
+
See also the discussion of scrolling [[ListBox]] controls horizontally using a '''Scrollbar''' control.
[[Slider|Slider]] control; [[RectControl|RectControl]] class.
 
  
 +
==See Also==
 +
[[Slider]] control; [[RectControl]] class.
  
[[Category:Controls]]
+
[[Category:Desktop]]
[[Category:Classes]]
+
[[Category:Desktop Controls]]

Latest revision as of 20:55, 13 September 2021

Class (inherits from RectControl)

The scrollbar control.

Events
Close GotFocus MouseExit
ConstructContextualMenu KeyDown MouseMove
ContextualMenuAction KeyUp MouseUp
DragEnter LostFocus MouseWheel
DragExit MouseDown Open
DragOver MouseDrag ValueChanged
DropObject MouseEnter


Properties
Active fa-lock-32.png LockLeft Scope fa-lock-32.png
AllowAutoDeactivate LockRight TabIndex
AllowFocus LockTop Tooltip
AllowLiveScrolling MaximumValue Top
AllowTabStop MinimumValue Transparent
Enabled MouseCursor TrueWindow fa-lock-32.png
Handle fa-lock-32.png MouseX fa-lock-32.png Value
Height MouseY fa-lock-32.png Visible
Index fa-lock-32.png Name fa-lock-32.png Width
Left PageStep Window fa-lock-32.png
LineStep PanelIndex
LockBottom Parent


Methods
AcceptFileDrop AcceptTextDrop Invalidate
AcceptPictureDrop Close Refresh
AcceptRawDataDrop DrawInto SetFocus

Notes

A Scrollbar can be either horizontal or vertical. To set its orientation programatically, set the height to be greater than the width for a vertical scrollbar. Set the width to be greater than the height for a horizontal scrollbar. The default thickness of the short side is 16 pixels, but it can be changed. You can narrow it in the IDE to get a mini-scrollbar.

Examples

Changing the maximum value of a Scrollbar at runtime:

Scrollbar1.MaximumValue = 200

Setting the text of a Label, control to the value of the Scrollbar when the user scrolls:

Sub ValueChanged()
Label1.Value = Str(Scrollbar1.Value)
End Sub

See also the discussion of scrolling ListBox controls horizontally using a Scrollbar control.

See Also

Slider control; RectControl class.