Difference between revisions of "UI.Behavior"
From GiderosMobile
| Line 17: | Line 17: | ||
'''params''': (table) any of Behavior parameters<br/> | '''params''': (table) any of Behavior parameters<br/> | ||
| − | === | + | === Examples === |
| + | '''Click and Long Click''' | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local gui=UI.Button.new() | local gui=UI.Button.new() | ||
| Line 40: | Line 41: | ||
screen:ui(gui) | screen:ui(gui) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
| + | '''Drag''' | ||
| + | <syntaxhighlight lang="lua"> | ||
| + | local gui = UI.Button.new() | ||
| + | gui:setDimensions(64, 48) | ||
| + | gui:setPosition(128, 128) | ||
| + | gui:setText("btn") | ||
| + | gui.name = "button" | ||
| + | stage:addChild(gui) | ||
| + | |||
| + | UI.Behavior.DragClick.new(gui) | ||
| + | |||
| + | function gui:onWidgetDragClick(w, x, y) | ||
| + | print(w.name, x, y) | ||
| + | end | ||
| + | </syntaxhighlight> | ||
| + | |||
{{UI}} | {{UI}} | ||
Latest revision as of 18:41, 5 September 2024
Available since: Gideros 2023.1
Class: UI
Description
Adds behaviors to a widget. Available behaviors are LongClick, Linger, DragMove, DragSize.
UI.Behavior.LongClick.new(widget,params)
A Behavior can have the following parameters:
- clsIndicator: the Indicator class to use UI.ProgressBar, UI.CircularProgress, ...
- szIndicator: the Indicator size
Parameters
widget: (sprite) the widget to add behavior to
params: (table) any of Behavior parameters
Examples
Click and Long Click
local gui=UI.Button.new()
gui:setDimensions(64, 48)
gui:setPosition(128, 128)
gui:setText("btn")
gui.name = "button"
stage:addChild(gui)
UI.Behavior.LongClick.new(gui,{ clsIndicator=UI.CircularProgress, szIndicator=32 })
function gui:onWidgetAction(w)
print(w.name, "clicked")
end
function gui:onWidgetLongAction(w)
print(w.name, "long clicked!")
end
-- we need a Screen widget to see the Circular Progress Indicator
local screen=UI.Screen.new()
screen:ui(gui)
Drag
local gui = UI.Button.new()
gui:setDimensions(64, 48)
gui:setPosition(128, 128)
gui:setText("btn")
gui.name = "button"
stage:addChild(gui)
UI.Behavior.DragClick.new(gui)
function gui:onWidgetDragClick(w, x, y)
print(w.name, x, y)
end
- UI.Accordion
- UI.Animation
- UI.Bar
- UI.Behavior
- UI.Border
- UI.BreadCrumbs
- UI.Builder
- UI.Button
- UI.Calendar
- UI.Checkbox
- UI.Combobox
- UI.ImageText
- UI.Keyboard
- UI.Label
- UI.Panel
- UI.Progress
- UI.Slider
- UI.Spinner
- UI.Splitpane
- UI.TabbedPane
- UI.Table
- UI.TextField
- UI.TimePicker
- UI.Toolbox
- UI.Tree
- UI.Viewport
- UI.WeekSchedule