-
-
Notifications
You must be signed in to change notification settings - Fork 26
Cursor
Slab offers a way to manage the drawing of controls through the cursor. Whenever a control is used, the cursor is automatically advanced based on the size of the control. By default, cursors are advanced vertically downward based on the control's height. However, functions are provided to move the cursor back up to the previous line or create an empty line to advance the cursor downward.
Slab.BeginWindow('MyFirstWindow', {Title = "My First Window"})
Slab.Text("X:")
Slab.SameLine()
if Slab.Input('X_Input', {Text = tostring(X), ReturnOnText = false, NumbersOnly = true}) then
X = tonumber(Slab.GetInputText())
end
Slab.Text("Y:")
Slab.SameLine()
if Slab.Input('Y_Input', {Text = tostring(Y), ReturnOnText = false, NumbersOnly = true}) then
Y = tonumber(Slab.GetInputText())
end
Slab.NewLine()
Slab.NewLine()
Slab.Text("Name:")
Slab.SameLine()
if Slab.Input('Name_Input', {Text = Name, ReturnOnText = false}) then
Name = Slab.GetInputText()
end
Slab.EndWindow()
The API also offers functions to indent or unindent the cursor. The anchor of the cursor is indented, thus allowing controls on subsequent lines to start at the indented locations.
Slab.BeginWindow('Indent', {Title = "Indent"})
Slab.Text("Line 1")
Slab.Indent()
Slab.Text("Line 2")
Slab.Text("Line 3")
Slab.Indent()
Slab.Text("Line 4")
Slab.Unindent()
Slab.Unindent()
Slab.Text("Line 5")
Slab.EndWindow()
Below is a list of functions that manage the cursor.
This forces the cursor to advance to the next line based on the height of the current font.
Parameter | Type | Description |
---|---|---|
n | + Integer | Number of newlines to use. Default is 1 |
This forces the cursor to move back up to the same line as the previous widget. By default, all Slab widgets will advance the cursor to the next line based on the height of the current line. By using this call with other widget calls, the user will be able to set up multiple widgets on the same line to control how a window may look.
Parameter | Type | Description |
---|---|---|
Options | Table | List of options that controls how the cursor should handle the same line. |
Option | Type | Description |
---|---|---|
Pad | Number | Extra padding to apply in the X direction. |
CenterY | Boolean | Controls whether the cursor should be centered in the Y direction on the line. By default the line will use the NewLineSize, which is the height of the current font to center the cursor. |
Sets the cursor position. The default behavior is to set the cursor position relative to the current window. The absolute position can be set if the 'Absolute' option is set.
Controls will only be drawn within a window. If the cursor is set outside of the current window context, the control will not be displayed.
Parameter | Type | Description |
---|---|---|
X | Number | The X coordinate to place the cursor. If nil, then the X coordinate is not modified. |
Y | Number | The Y coordinate to place the cursor. If nil, then the Y coordinate is not modified. |
Options | Table | List of options that control how the cursor position should be set. |
Option | Type | Description |
---|---|---|
Absolute | Boolean | If true, will place the cursor using absolute coordinates. |
Advances the anchored X position of the cursor. All subsequent lines will begin at the new cursor position. This function has no effect when columns are present.
Parameter | Type | Description |
---|---|---|
Width | Number | How far in pixels to advance the cursor. If nil, then the default value identified by the 'Indent' property in the current style is used. |
Retreats the anchored X position of the cursor. All subsequent lines will begin at the new cursor position. This function has no effect when columns are present.
Parameter | Type | Description |
---|---|---|
Width | Number | How far in pixels to retreat the cursor. If nil, then the default value identified by the 'Indent' property in the current style is used. |