UI.Behavior

From GiderosMobile
Revision as of 18:41, 5 September 2024 by MoKaLux (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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