-
Notifications
You must be signed in to change notification settings - Fork 0
Widgets
Widgets are objects that can be added to a screen object. They are used to display text, buttons, images, etc. on the screen.
Calling a widget function with also add the widget to the screen.
All widgets get called with a args
table, which contains values that are used to draw the widget.
Widgets have a unique ID, which is normally assigned automatically, but can be manually assigned by passing an id
value to the args
table.
- screenObject:text
- screenObject:textarea
- screenObject:button
- screenObject:checkbox
- screenObject:toggleSwitch
Description: creates and adds a text widget to the screen
Parameters: args
- a table containing the following values:
-
x
- the x position of the widget -
y
- the y position of the widget -
text
- the text to display -
color
- the color of the text (optional, default:colors.white
) -
background
- the background color of the text (optional, default:colors.black
) -
id
- manually assign an ID to the widget
Returns: the widget object
Description: creates and adds a textarea widget to the screen, which wraps text in the given width
Parameters: args
- a table containing the following values:
-
x
- the x position of the widget -
y
- the y position of the widget -
width
- the width of the widget -
height
- the height of the widget -
text
- the text to display -
color
- the color of the text (optional, default:colors.white
) -
background
- the background color of the text (optional, default:colors.black
) -
id
- manually assign an ID to the widget
Returns: the widget object
Description: creates and adds a button widget to the screen
Parameters: args
- a table containing the following values:
-
x
- the x position of the widget -
y
- the y position of the widget -
text
- the text to display -
color
- the color of the text (optional, default:colors.white
) -
background
- the background color of the text (optional, default:colors.black
) -
callback
- the function to call when the button is clicked (parameters:x
,y
,button
) -
id
- manually assign an ID to the widget
Returns: the widget object
Description: creates and adds a checkbox widget to the screen
Parameters: args
- a table containing the following values:
-
x
- the x position of the widget -
y
- the y position of the widget -
text
- the text to display -
color
- the color of the text (optional, default:colors.white
) -
background
- the background color of the text (optional, default:colors.black
) -
checked
- whether the checkbox is checked or not (optional, default:false
) -
callback
- the function to call when the checkbox is clicked (parameters:x
,y
,button
,checked
) -
id
- manually assign an ID to the widget
Returns: the widget object
Description: creates and adds a radio widget to the screen
Parameters: args
- a table containing the following values:
-
x
- the x position of the widget -
y
- the y position of the widget -
color
- the color of the text (optional, default:colors.white
) -
background
- the background color of the text (optional, default:colors.black
) -
options
- a table containing the options to display -
selected
- the selected option (optional, default:1
) -
callback
- the function to call when the radio is changed (optional, parameters:selected
)
Description: creates and adds a switch widget to the screen
Parameters: args
- a table containing the following values:
-
x
- the x position of the widget -
y
- the y position of the widget -
text
- the text to display -
color
- the color of the text (optional, default:colors.white
) -
background
- the background color of the text (optional, default:colors.black
) -
state
- whether the switch is checked or not (optional, default:false
) -
callback
- the function to call when the switch is clicked (parameters:x
,y
,button
,state
) -
id
- manually assign an ID to the widget
Returns: the widget object
Description: creates and adds an input widget to the screen
Parameters: args
- a table containing the following values:
-
x
- the x position of the widget -
y
- the y position of the widget -
width
- the width of the widget (optional, default: length of the placeholder text) -
placeholder
- the placeholder text to display -
color
- the color of the text (optional, default:colors.white
) -
background
- the background color of the text (optional, default:colors.black
) -
placeholderColor
- the color of the placeholder text (optional, default:colors.gray
) -
callback
- the function to call when the input is changed (parameters:text
) -
id
- manually assign an ID to the widget
Returns: the widget object
Description: creates and adds an input Area widget to the screen
Parameters: args
- a table containing the following values:
-
x
- the x position of the widget -
y
- the y position of the widget -
width
- the width of the widget -
height
- the height of the widget -
placeholder
- the placeholder text to display -
color
- the color of the text (optional, default:colors.white
) -
background
- the background color of the text (optional, default:colors.black
) -
placeholderColor
- the color of the placeholder text (optional, default:colors.gray
) -
callback
- the function to call when the input is changed (parameters:text
) -
id
- manually assign an ID to the widget
Returns: the widget object
Description: creates and adds a tab switch widget to the screen
Parameters: args
- a table containing the following values:
-
x
- the x position of the widget -
y
- the y position of the widget -
color
- the color of the text (optional, default:colors.white
) -
background
- the background color of the text (optional, default:colors.black
) -
selectedColor
- color of the text of the selected tab (optional, default:colors.white
) -
selectedBackground
- color of the background of the selected tab (optional, defaultcolors.red
) -
callback
- the function to call when the input is changed (parameters:text
) -
id
- manually assign an ID to the widget
Returns: the widget object
cctinker is licensed under the MIT LICENSE | © 2023 Loewe_111