Module helpers.vSelection

(bool) enforce that at least one item remains selected at all times

Functions

clear_selection ()
select_all ()
toggle_index (idx) toggle a selected bar on or off, depending on its current state
reset () avoid that the selection picks up a double-press, e.g.
contains_index (idx) check if a given index is selected
select_previous () select next item
keyhandler (key) TODO: * support modifier keys (multi-select only) * page up/down, home/end
set_indices (t) Getters and setters
set_require_selection (val)
set_index (idx)
set_mode (val)

Fields

self.mode (vSelection.SELECT_MODE) single or multi-selection?
self.index (int) the index of the (first) selected item, or 0 when no selection note: setting this property while in multi-select mode will "collapse" the selection to a single item, while getting will return the first item
self.indices (table) note: the sequence reflects the order in which the items were selected: if you select the third item, and then the first item, this property contains an array of values in the following sequence: {3,1}
self.num_items (int) vSelection does not contain a direct reference to the data - instead you provide it with @num_items - this is used for determining if a given index is valid, how many items to select when selecting all
self.last_selected_index (int) each time a single index is set, the index/time is saved this makes it possible to detect a double-press event
self.doublepress_timeout (number) the timeout for detecting double-presses (in seconds)
self.doublepress_observable (ObservableBang), fired on double-press note: use "self.last_selected_index" to obtain the item


Functions

clear_selection ()

Returns:

  1. bool (true when changed)
  2. table (removed_items)
  3. bool (true when changed)
  4. table (added_items)
select_all ()

Returns:

  1. bool (true when changed)
  2. table (added_items)
toggle_index (idx)
toggle a selected bar on or off, depending on its current state

Parameters:

  • idx

Returns:

  1. bool (true when changed)
  2. table (added_items)
  3. table (removed_items)
reset ()
avoid that the selection picks up a double-press, e.g. when displaying a new set of data
contains_index (idx)
check if a given index is selected

Parameters:

  • idx (number)

Returns:

    int (index)
select_previous ()
select next item
keyhandler (key)
TODO: * support modifier keys (multi-select only) * page up/down, home/end

Parameters:

  • key

Returns:

    key (table) for unhandled keys
set_indices (t)
Getters and setters

Parameters:

  • t TRACE("vSelection set_indices(t)",t)

Returns:

  1. bool (true when changed, false on invalid index or mode)
  2. table>int (added_items)
  3. table>int (removed_items)
  4. bool (when changed)
  5. table (added_items)
  6. table (removed_items)
set_require_selection (val)

Parameters:

  • val

Returns:

  1. bool (when changed)
  2. table (added_items)
  3. table (removed_items)
  4. bool (when changed)
  5. table (added_items)
  6. table (removed_items)
set_index (idx)

Parameters:

  • idx

Returns:

  1. bool (when changed)
  2. table (added_items)
  3. table (removed_items)
  4. bool (when changed)
  5. table (added_items)
  6. table (removed_items)
set_mode (val)

Parameters:

  • val

Returns:

  1. bool (when changed)
  2. table (added_items)
  3. table (removed_items)

Fields

self.mode
(vSelection.SELECT_MODE) single or multi-selection?
self.index
(int) the index of the (first) selected item, or 0 when no selection note: setting this property while in multi-select mode will "collapse" the selection to a single item, while getting will return the first item
self.indices
(table) note: the sequence reflects the order in which the items were selected: if you select the third item, and then the first item, this property contains an array of values in the following sequence: {3,1}
self.num_items
(int) vSelection does not contain a direct reference to the data - instead you provide it with @num_items - this is used for determining if a given index is valid, how many items to select when selecting all
self.last_selected_index
(int) each time a single index is set, the index/time is saved this makes it possible to detect a double-press event
self.doublepress_timeout
(number) the timeout for detecting double-presses (in seconds)
self.doublepress_observable
(ObservableBang), fired on double-press note: use "self.last_selected_index" to obtain the item
generated by LDoc 1.4.2