Skip to content

Widget

[Source]

Base trait for all widget actors. Users implement their own actors with this trait.

Required: state() returns the WidgetState field, render() produces the grid. All other behaviors have default implementations.

The fun ref methods are uncallable from outside the actor because external references are always tag capability.

trait tag Widget

Public Behaviours

resize

[Source]

Update allocated size and re-render.

be resize(
  w: USize val,
  h: USize val)

Parameters


trigger_render

[Source]

Force a re-render and send to parent.

be trigger_render()

receive_key

[Source]

Handle a key event. Default: ignore.

be receive_key(
  key: KeyEvent val)

Parameters


receive_focus

[Source]

Called when this widget receives focus. Default: re-render.

be receive_focus()

receive_blur

[Source]

Called when this widget loses focus. Default: re-render.

be receive_blur()

set_debug_bg

[Source]

Set a debug background color to visualize this widget's allocated space. Use Default to disable.

be set_debug_bg(
  color: (Default val | Black val | Red val | 
    Green val | Yellow val | Blue val | 
    Magenta val | Cyan val | White val | 
    BrightBlack val | BrightRed val | BrightGreen val | 
    BrightYellow val | BrightBlue val | BrightMagenta val | 
    BrightCyan val | BrightWhite val | Rainbow val))

Parameters


Public Functions

state

[Source]

Return the widget's state. Backed by a field on the actor.

fun ref state()
: WidgetState ref

Returns


render

[Source]

Produce a grid representing the current widget state.

fun ref render()
: Grid val

Returns


render_and_send

[Source]

Render the widget and send the grid to the parent.

fun ref render_and_send()
: None val

Returns