Module helpers.vSelection
(bool) enforce that at least one item remains selected at all times
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:
-
bool (true when changed)
-
table (removed_items)
-
bool (true when changed)
-
table (added_items)
-
select_all ()
-
Returns:
-
bool (true when changed)
-
table (added_items)
-
toggle_index (idx)
-
toggle a selected bar on or off, depending on its current state
Parameters:
Returns:
-
bool (true when changed)
-
table (added_items)
-
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:
Returns:
int (index)
-
select_previous ()
-
select next item
-
keyhandler (key)
-
TODO:
* support modifier keys (multi-select only)
* page up/down, home/end
Parameters:
Returns:
key (table) for unhandled keys
-
set_indices (t)
-
Getters and setters
Parameters:
- t
TRACE("vSelection
set_indices(t)",t)
Returns:
-
bool (true when changed, false on invalid index or mode)
-
table>int (added_items)
-
table>int (removed_items)
-
bool (when changed)
-
table (added_items)
-
table (removed_items)
-
set_require_selection (val)
-
Parameters:
Returns:
-
bool (when changed)
-
table (added_items)
-
table (removed_items)
-
bool (when changed)
-
table (added_items)
-
table (removed_items)
-
set_index (idx)
-
Parameters:
Returns:
-
bool (when changed)
-
table (added_items)
-
table (removed_items)
-
bool (when changed)
-
table (added_items)
-
table (removed_items)
-
set_mode (val)
-
Parameters:
Returns:
-
bool (when changed)
-
table (added_items)
-
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