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
Input.at_  content
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, #'multiple in styles],

    ~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.

The styles list must contain exactly one of #'single and #'multiple.

An input style option:

  • #'single: Shows a single line of text input, and treats the Enter or Return key as a special event. The input content is not automatically prevented from containing a newline character in pasted text, however.

  • #'single: Shows multiple lines of text input, and creates a new line of text in response to the Enter or Return key.

  • #'password: Renders characters typed into the input field as bullets.

  • #'horizontal_label: When the input field has a label, show it to the left of the field. Horizontal label placement is the default if #'vertical_label is not specified, and #'horizontal_label and #'vertical_label are mutually exclusive.

  • #'vertical_label: When the progress gauge has a label, show it above the gauge.

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 for an input field using the style #'single. The #'focus_in and #'focus_out events report keyboard-focus changes.