widgets.on

Observes a supported widget event with a Lua callback.

Syntax

ue.widgets.on(widget: UObjectProxy, event_name: string, callback: function, options?: table) -> integer?, string?

Parameters

ParameterTypeDescription
widgetUObjectProxyWidget to observe.
event_namestringSupported event name; optional on_ prefix.
callbackfunction(value, old_value, widget, id, event)Called when state changes.
options.immediateboolean?Deliver current state on the next tick.

Returns

TypeDescription
integerWidget binding ID.
nil, stringWidget, event, or state getter is unsupported.

Example

local click_id = assert(ue.widgets.on(
    button,
    "clicked",
    function(value, old_value, widget)
        print(widget:name())
    end
))

Notes

  • Convenience helpers include on_click, on_pressed, on_released, on_hover, on_unhover, on_focus, on_blur, on_mouse_capture, on_mouse_capture_lost, on_value_changed, on_check_state_changed, on_selection_changed, on_text_changed, on_visibility_changed, and on_enabled_changed.

On this page