On this page:
Button
Checkbox
Checkbox.at_  is_  checked
Choice
Choice.at_  selection
Slider
Slider.at_  value
Label
Label.at_  label
Input
Spacer
Button.Style  Symbol
Button.Label  Position
Choice.Style  Symbol
Slider.Style  Symbol
Input.Style  Symbol
8.12

7 Controls🔗ℹ

class

class Button():

  implements View

  constructor (

    label :: MaybeObs.of(LabelString

                           || Bitmap

                           || matching([_ :: Bitmap,

                                        _ :: LabelString,

                                        _ :: Button.LabelPosition])),

    ~action: action :: Function.of_arity(0) = fun (): #void,

    ~is_enabled: is_enabled :: MaybeObs.of(Boolean) = #true,

    ~style: style :: MaybeObs.of(List.of(Button.StyleSymbol)) = [],

    ~margin: margin :: MaybeObs.of(Margin) = [0, 0],

    ~min_size: min_size :: MaybeObs.of(Size) = [#false, #false],

    ~stretch: stretch :: MaybeObs.of(Stretch) = [#true, #true],

  )

Creates a button. When rendered, the function call action() is performed when the button is clicked.

class

class Checkbox():

  implements View

  constructor (

    label :: MaybeObs.of(LabelString),

    ~is_checked: is_checked :: MaybeObs.of(Boolean) = #false,

    ~action: action :: Function.of_arity(1) = set_is_checked,

    ~is_enabled: is_enabled :: MaybeObs.of(Boolean) = #true,

  )

 

property

property (cb :: Checkbox).at_is_checked :: Obs.of(Boolean)

Creates a checkbox. When rendered, the function call action(now_checked) is performed when the checkbox is clicked, where now_checked indicates the state of the checkbox.

If is_checked is not an observable, then an observable at_is_checked is created with initial value is_checked. Otherwise, at_is_checked is is_checked. A observable derived from at_is_checked can be obtained from the Checkbox.at_is_checked property.

The default set_is_checked function for action corresponds to

fun (on):

  at_is_checked.value := on

class

class Choice():

  implements View

  constructor (

    choices :: MaybeObs.of(List),

    ~choice_to_label: choice_to_label :: Function.of_arity(1) = values,

    ~choice_equal: choice_equal :: Function.of_arity(2) = fun (a, b): a == b,

    ~selection: selection :: MaybeObs.of(Any) = #false,

    ~action: action :: maybe(Function.of_arity(1)) = #false,

    ~label: label :: MaybeObs.of(maybe(LabelString)) = #false,

    ~style: style :: MaybeObs.of(List.of(Choice.StyleSymbol)) = [],

    ~is_enabled: is_enabled :: MaybeObs.of(Boolean) = #true,

    ~min_size: min_size :: MaybeObs.of(Size) = [#false, #false],

    ~stretch: stretch :: MaybeObs.of(Stretch) = [#true, #true],

  )

 

property

property (chc :: Choice).at_selection :: Obs

Creates a popup choice selecotr where choices provides the number and identity of choices, and selection determines which of the tabs is selected. When rendered, the function call action(now_selected) is performed when the selection is changed, where now_selected indicates the newly selected choice.

If selection is not an observable, then an observable at_selection is created with initial value selection. Otherwise, at_selection is selection. A observable derived from at_selection can be obtained from the Choice.at_selection property.

The choice_to_label function converts an item in choices to a label to be shown for the control, and choice_equal defines equality for choice identities. By default, choices is expected to be a list of LabelString, since choice_to_label is the identity function.

The default action function corresponds to

fun (selected):

  at_selection.value := selected

class

class Slider():

  implements View

  constructor (

    label :: MaybeObs.of(maybe(LabelString)) = #false,

    ~value: value :: MaybeObs.of(PositionInteger) = 0,

    ~min_value: min_value :: MaybeObs.of(PositionInteger) = 0,

    ~max_value: max_value :: MaybeObs.of(PositionInteger) = 100,

    ~action: action :: maybe(Function.of_arity(1)) = #false,

    ~is_enabled: is_enabled :: MaybeObs.of(Boolean) = #true,

    ~min_size: min_size :: MaybeObs.of(Size) = [#false, #false],

    ~stretch: stretch :: MaybeObs.of(Stretch) = [#true, #true],

    ~style: style :: List.of(Slider.StyleSymbol) = [#'horizontal],

  )

 

property

property (sldr :: Slider).at_value :: Obs.of(PositionInteger)

Creates a slider. When rendered, the function call action(now_val) is performed when the slider is changed, where now_val indicates the value of the slider.

If value is not an observable, then an observable at_value is created with initial value value. Otherwise, at_value is value. A observable derived from at_value can be obtained from the Checkbox.at_value property.

The default set_value function for action corresponds to

fun (val):

  at_value.value := val

class

class Label():

  implements View

  constructor (

    label :: MaybeObs.of(LabelString),

    ~color: color :: MaybeObs.of(maybe(Color)) = #false,

    ~font: font :: MaybeObs.of(Font) = Label.normal_control_font,

  )

 

property

property (lbl :: Label).at_label :: Obs.of(LabelString)

Creates a text label.

If label is not an observable, then an observable at_label is created with initial value value. Otherwise, at_label is value. A observable derived from at_value can be obtained from the Label.at_label property.

class

class Input():

  implements View

  constructor (

    content :: MaybeObs.of(Any),

    ~action: action :: maybe(Function.of_arity(2)) = #false,

    ~label: label :: MaybeObs.of(LabelString) = "",

    ~is_enabled: is_enabled :: MaybeObs.of(Boolean) = #true,

    ~background_color: bg_color :: MaybeObs.of(maybe(Color)) = #false,

    ~style: style :: MaybeObs.of(List.of(Input.StyleSymbol)) = [#'single],

    ~font : font :: Font = normal_control_font,

    ~margin: margin :: MaybeObs.of(Margin) = [0, 0],

    ~min_size: min_size :: MaybeObs.of(Size) = [#false, #false],

    ~stretch: stretch :: MaybeObs.of(Stretch) = [#true, #true],

    ~mixin: mixin :: Function = values,

    ~is_equal_value: is_equal :: maybe(Function.of_arity(2)) = (fun (a, b): a == b),

    ~value_to_text: val_to_txt :: Function = values

  )

Returns a representation of a text field that calls action on change. The first argument to the action is the type of event that caused the input to change and the second is the contents of the text field.

The ~is_equal_value argument controls when changes to the input data are reflected in the contents of the field. The contents of the input field only change when the new value of the underlying observable is not == to the previous one. The only exception to this is when the textual value (via ~value_to_text) of the observable is the empty string, in which case the input is cleared regardless of the value of the underlying observable.

The ~value_to_text argument controls how the input values are rendered to strings. If not provided, value must be either a string? or an observable of strings.

Returns a representation of a spacer. Spacers extend to fill the space of their parents.

Satisfied by the following symbols:

Satisfied by the following symbols:

Satisfied by the following symbols:

Satisfied by the following symbols:

Satisfied by the following symbols: