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:
Table
Table.at_  selection
Table.Style  Symbol
Table.Style  Symbol.single
Table.Style  Symbol.multiple
Table.Style  Symbol.extended
Table.Style  Symbol.column_  headers
Table.Style  Symbol.clickable_  headers
Table.Style  Symbol.reorderable_  headers
Table.Style  Symbol.variable_  columns
Table.Style  Symbol.horizontal_  label
Table.Style  Symbol.vertical_  label
Table.Event
Table.Event.select
Table.Event.double_  click
Table.Event.column
Table.Selection

image

class

class gui.Table():

  implements WindowChildView

  constructor (

    columns :: maybe(List.of(View.LabelString)),

    choices :: ObsOrValue.of(Array),

    ~action: action :: (Table.Event, Array, Table.Selection) -> ~any

               = values,

    ~choice_to_row: choice_to_row :: Any -> Array.now_of(View.LabelString)

                      = values,

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

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

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

    ~style: style :: List.of(Table.StyleSymbol)

              = [#'single, #'column_headers,

                 #'clickable_headers, #'reorderable_headers],

    ~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],

    ~column_widths: column_widths :: ObsOrValue.of(List.of(Table.CellWidth))

                      = [],

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

  )

 

property

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

Creates a list-row selector where choices provides column labels (and, implicitly, the column column), choices provides the number and identity of rows, and selection determines which of the lines are selected. When rendered, the function call action(event, choices, selection) is performed when the table is changed, where event indicates the kind of action, choices indicates the choices at the time of the event, and choice selection identifies the selected rows.

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

The choice_to_row function converts an element of choices to an array of label strings to show in the table.

The style list must contain exactly one of single, #'multiple, and #'extended.

A table style option.

  • #'single: Creates a table where at most one row can be selected at a time. On some platforms, the user can deselect the (sole) selected item. The #'single, #'multiple, and #'extended styles are mutually exclusive, and one of them must be present.

  • #'multiple: Creates a multiple-selection table where a single click deselects other rows and selects a new row. Use this style for a table when single-selection is common, but multiple selections are allowed.

  • #'extended: Creates a multiple-selection table where a single click extends or contracts the selection by toggling the clicked row. Use this style for a table when multiple selections are the rule rather than the exception.

    The #'multiple and #'extended styles determine a platform-independent interpretation of unmodified mouse clicks, but dragging, shift-clicking, control-clicking, etc. have platform-standard interpretations. Whatever the platform-specific interface, the user can always select disjoint sets of rows or deselect rows (and leave no items selected).

  • #'column_headers: Shows the table column names.

  • #'clickable_headers: Allows the user to click a table column, where clicks are handled by the table’s ~action callback.

  • #'reorderable_headers: Allows the user to reorder table columns, where the table’s ~action callback receives a notification of reordering.

  • #'variable_columns: Allows new columns to be added dynamically.

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

enumeration

enum gui.Table.Event

| select

| double_click

| column

An event provided to the ~action callback function of an Table. A #'select event reports a change in the selection, #'double_click reports a double click, and #'column indicates a change in column order.

annotation

gui.Table.Selection

Equivalent to maybe(Int || List.of(Int)) to represent a Table selection.