3.3.5 Controls
3.3.5.1 Button
3.3.5.2 Checkbox
3.3.5.3 Choice
3.3.5.4 Radio  Choice
3.3.5.5 List  Choice
3.3.5.6 Table
3.3.5.7 Slider
3.3.5.8 Progress
3.3.5.9 Input
3.3.5.10 Label
3.3.5.11 Image
3.3.5.12 Spacer
On this page:
Input.Style  Symbol
Input.Style  Symbol.single
Input.Style  Symbol.multiple
Input.Style  Symbol.password
Input.Style  Symbol.horizontal_  label
Input.Style  Symbol.vertical_  label
Input.Style  Symbol.hscroll
Input.Event
Input.Event.input
Input.Event.return
Input.Event.focus_  in
Input.Event.focus_  out

image   image

class

class gui.Input():

  implements WindowChildView

  constructor (

    content :: ObsOrValue.of(Any),

    ~action: action :: maybe((Input.Event, String) -> ~any) = #false,

    ~label: label :: ObsOrValue.of(View.LabelString) = "",

    ~choices: choices :: maybe(ObsOrValue.of(List.of(View.LabelString)))

                = #false,

    ~enable: enable :: ObsOrValue.of(Boolean) = #true,

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

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

    ~font : font :: draw.Font = View.normal_control_font,

    ~margin: margin :: ObsOrValue.of(View.Margin) = [2, 2],

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

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

    ~window_callbacks: window_callbacks :: maybe(WindowCallbacks) = #false,

    ~is_equal_value: is_equal :: Function.of_arity(2) = (_ == _),

    ~value_to_text: val_to_txt :: Function = values

  )

 

property

property (inp :: gui.Input).at_content :: Obs.of(Any)

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.

If the ~choices argument is not #false, it provides a list of suggestions via a popup menu. When a user selects an item in the popup menu, it is copied into 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.

The Input.at_content property returns an observable that is updated whenever the input’s value changes through an action (as also reported via action) or via content as an observable.

An input style option.

enumeration

enum gui.Input.Event

| input

| return

| focus_in

| focus_out

An event provided to the ~action callback function of an Input. The event #'input corresponds to any change to the input text, while #'return indicates that the Return or Enter key was pressed. The #'focus_in and #'focus_out events report keyboard-focus changes.