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:
Choice
Choice.at_  selection
Choice.Style
Choice.Style.horizontal_  label
Choice.Style.vertical_  label

image

class

class gui.Choice():

  implements WindowChildView

  constructor (

    choices :: ObsOrValue.of(List),

    ~choice_to_label: choice_to_label :: Any -> Any = values,

    ~choice_equal: choice_equal :: Function.of_arity(2) = (_ == _),

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

    ~action: action :: Any -> ~any = values,

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

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

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

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

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

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

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

  )

 

property

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

Creates a popup choice selector where choices provides the number and identity of choices, and selection determines which of the tabs is selected.

The function call action(now_selected) is performed when the selection is changed by a user, where now_selected indicates the newly selected choice.

The Choice.at_selection property returns an observable that is updated whenever the choice popup’s state changes through an action (as also reported via action) or via selection as an observable.

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

See View.LabelString for information about keyboard mnemonics in label.

See Geometry Management for information about ~margin, ~min_size, and ~stretch.

The ~window_callbacks argument configures callbacks that are common to all WindowChildViews. See WindowCallbacks for more information.

A choice control style option:

  • #'horizontal_label: When the choice control has a label, show it to the left of the control. 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 choice control has a label, show it above the control.