Interactive canvas element.
An interactive is a named group that responds to user input. It
requires an explicit id (first positional argument) and supports
click, hover, drag, focus, and accessibility fields.
On the wire this encodes as type: "group" (the renderer has no
separate interactive type). The split is purely an SDK-side API
improvement: group is structural, interactive is for elements
that respond to user input.
Example
interactive "btn", on_click: true, cursor: "pointer" do
rect(0, 0, 100, 40, fill: "#3498db")
end
Summary
Functions
Accessibility annotations (role, label, etc.).
Converts this widget struct to a ui_node() map.
Clip rectangle.
CSS cursor on hover (e.g. "pointer", "grab").
Constrain drag to an axis.
Drag boundary constraints.
Enable drag events.
Appends multiple children to the widget.
Focus ring corner radius in pixels.
Style overrides when focused.
Add to the Tab focus order.
Explicit hit test rectangle.
Style overrides on hover.
Creates a new element without an explicit ID (auto-assigned by parent container).
Creates a new element with the given ID and keyword options.
Enable click events.
Enable hover events.
Style overrides when pressed.
Appends a child to the widget.
Show the default focus ring.
Tooltip text on hover.
List of transform descriptors.
Returns the element type string for the wire protocol.
Applies keyword options to an existing widget struct.
Types
@type option() :: ((((((((((((((({:transforms, term()} | {:clip, term()}) | {:on_click, boolean()}) | {:on_hover, boolean()}) | {:draggable, boolean()}) | {:drag_axis, :x | :y | :both}) | {:drag_bounds, %Plushie.Canvas.DragBounds{ max_x: term(), max_y: term(), min_x: term(), min_y: term() } | keyword() | map()}) | {:cursor, String.t() | atom()}) | {:hit_rect, %Plushie.Canvas.HitRect{h: term(), w: term(), x: term(), y: term()} | keyword() | map()}) | {:tooltip, String.t() | atom()}) | {:hover_style, %Plushie.Canvas.ShapeStyle{ fill: term(), opacity: term(), stroke: term() } | keyword() | map()}) | {:pressed_style, %Plushie.Canvas.ShapeStyle{ fill: term(), opacity: term(), stroke: term() } | keyword() | map()}) | {:focus_style, %Plushie.Canvas.ShapeStyle{ fill: term(), opacity: term(), stroke: term() } | keyword() | map()}) | {:show_focus_ring, boolean()}) | {:focus_ring_radius, number()}) | {:a11y, term()}) | {:focusable, boolean()}
@type t() :: %Plushie.Canvas.Interactive{ a11y: term() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, children: [Plushie.Widget.ui_node()], clip: term() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, cursor: (String.t() | atom()) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, drag_axis: (:x | :y | :both) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, drag_bounds: %Plushie.Canvas.DragBounds{ max_x: term(), max_y: term(), min_x: term(), min_y: term() } | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, draggable: boolean() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, focus_ring_radius: number() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, focus_style: %Plushie.Canvas.ShapeStyle{fill: term(), opacity: term(), stroke: term()} | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, focusable: boolean() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, hit_rect: %Plushie.Canvas.HitRect{h: term(), w: term(), x: term(), y: term()} | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, hover_style: %Plushie.Canvas.ShapeStyle{fill: term(), opacity: term(), stroke: term()} | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, id: String.t() | nil, on_click: boolean() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, on_hover: boolean() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, pressed_style: %Plushie.Canvas.ShapeStyle{fill: term(), opacity: term(), stroke: term()} | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, show_focus_ring: boolean() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, tooltip: (String.t() | atom()) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, transforms: term() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil }
Functions
Accessibility annotations (role, label, etc.).
Accepts term().
@spec build(widget :: t()) :: Plushie.Widget.ui_node()
Converts this widget struct to a ui_node() map.
Clip rectangle.
Accepts term().
CSS cursor on hover (e.g. "pointer", "grab").
Accepts String.t() | atom().
Constrain drag to an axis.
Accepts :x | :y | :both.
@spec drag_bounds( widget :: t(), value :: (%Plushie.Canvas.DragBounds{ max_x: term(), max_y: term(), min_x: term(), min_y: term() } | keyword() | map()) | nil ) :: t()
Drag boundary constraints.
Accepts %Plushie.Canvas.DragBounds{}.
Enable drag events.
Accepts boolean().
@spec extend(widget :: t(), children :: [Plushie.Widget.child()]) :: t()
Appends multiple children to the widget.
Focus ring corner radius in pixels.
Accepts number().
@spec focus_style( widget :: t(), value :: (%Plushie.Canvas.ShapeStyle{fill: term(), opacity: term(), stroke: term()} | keyword() | map()) | nil ) :: t()
Style overrides when focused.
Accepts %Plushie.Canvas.ShapeStyle{}.
Add to the Tab focus order.
Accepts boolean().
@spec hit_rect( widget :: t(), value :: (%Plushie.Canvas.HitRect{h: term(), w: term(), x: term(), y: term()} | keyword() | map()) | nil ) :: t()
Explicit hit test rectangle.
Accepts %Plushie.Canvas.HitRect{}.
@spec hover_style( widget :: t(), value :: (%Plushie.Canvas.ShapeStyle{fill: term(), opacity: term(), stroke: term()} | keyword() | map()) | nil ) :: t()
Style overrides on hover.
Accepts %Plushie.Canvas.ShapeStyle{}.
Creates a new element without an explicit ID (auto-assigned by parent container).
Creates a new element with the given ID and keyword options.
Enable click events.
Accepts boolean().
Enable hover events.
Accepts boolean().
@spec pressed_style( widget :: t(), value :: (%Plushie.Canvas.ShapeStyle{fill: term(), opacity: term(), stroke: term()} | keyword() | map()) | nil ) :: t()
Style overrides when pressed.
Accepts %Plushie.Canvas.ShapeStyle{}.
@spec push(widget :: t(), child :: Plushie.Widget.child()) :: t()
Appends a child to the widget.
Show the default focus ring.
Accepts boolean().
Tooltip text on hover.
Accepts String.t() | atom().
List of transform descriptors.
Accepts term().
@spec type_name() :: String.t()
Returns the element type string for the wire protocol.
Applies keyword options to an existing widget struct.