Difference between revisions of "UI.Spinner"
From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2023.1<br/> '''Class:''' UI<br/> === Description === Creates a Spinner widget. <syntaxhighlight lang="lua"> UI.Spinner.new(params...") |
|||
Line 19: | Line 19: | ||
'''params''': (table) the default parameters for the Spinner widget<br/> | '''params''': (table) the default parameters for the Spinner widget<br/> | ||
− | === | + | === Examples === |
+ | '''With Numbers''' | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local gui = UI.Spinner.new({Min=0, Max=100, Step=10, Format="Done: %d%%", Looping=true}) | local gui = UI.Spinner.new({Min=0, Max=100, Step=10, Format="Done: %d%%", Looping=true}) | ||
+ | gui:setDimensions(128, 32) | ||
+ | gui:setColor(0xaacc00) | ||
+ | gui:setPosition(50, 50) | ||
+ | |||
+ | function gui:onWidgetChange(w) | ||
+ | print(w.value) | ||
+ | end | ||
+ | |||
+ | local screen=UI.Screen.new() -- needed to add the Spinner widget arrows | ||
+ | screen:ui(gui) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | '''With Strings''' | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | local data = { "A", "B", "C", "D", "E" } | ||
+ | local gui = UI.Spinner.new(data) | ||
gui:setDimensions(128, 32) | gui:setDimensions(128, 32) | ||
gui:setColor(0xaacc00) | gui:setColor(0xaacc00) |
Revision as of 00:12, 17 October 2023
Available since: Gideros 2023.1
Class: UI
Description
Creates a Spinner widget.
UI.Spinner.new(params)
params is a table which can have the following properties:
- Min: (number) the minimum Spinner widget value
- Max: (number) the maximum Spinner widget value
- Step: (number) the Spinner widget steps increment value
- Format: (string) the Spinner widget text format
- Looping: (bool) allows the Spinner widget value to loop (default = false)
Parameters
params: (table) the default parameters for the Spinner widget
Examples
With Numbers
local gui = UI.Spinner.new({Min=0, Max=100, Step=10, Format="Done: %d%%", Looping=true})
gui:setDimensions(128, 32)
gui:setColor(0xaacc00)
gui:setPosition(50, 50)
function gui:onWidgetChange(w)
print(w.value)
end
local screen=UI.Screen.new() -- needed to add the Spinner widget arrows
screen:ui(gui)
With Strings
local data = { "A", "B", "C", "D", "E" }
local gui = UI.Spinner.new(data)
gui:setDimensions(128, 32)
gui:setColor(0xaacc00)
gui:setPosition(50, 50)
function gui:onWidgetChange(w)
print(w.value)
end
local screen=UI.Screen.new() -- needed to add the Spinner widget arrows
screen:ui(gui)