State Objects¶
To keep the state of an Element
across multiple invocations of
view()
, e.g. the cursor position in a
text_input()
, you have to supply a state object.
Warning
If the same state object is used for multiple elements in the same
view()
call, only the first element get displayed.
All and further elements with the same state become no_element()
.
Overview¶
The state of a |
|
The state of a |
|
The state of a |
|
The state of a |
|
The state of a |
Details¶
- class pyiced.PickListState¶
The state of a
pick_list()
.
- class pyiced.ScrollableState¶
The state of a
scrollable()
.Warning
If the state is currently in use, calling its methods will fail.
- is_scroll_box_touched()¶
Returns whether the scroll box is currently touched or not.
- Returns
Yes or no
- Return type
- is_scroller_grabbed()¶
Returns whether the scroller is currently grabbed or not.
- Returns
Yes or no
- Return type
- offset(bounds, content_bounds)¶
The current scrolling offset of the ScrollableState, given the bounds of the Scrollable and its contents.
- scroll(delta_y, bounds, content_bounds)¶
Apply a scrolling offset to the current ScrollableState, given the bounds of the Scrollable and its contents.
- scroll_to(percentage, bounds, content_bounds)¶
Moves the scroll position to a relative amount, given the bounds of the Scrollable and its contents.
0.0 represents scrollbar at the top, while 1.0 represents scrollbar at the bottom.
- class pyiced.TextInputState¶
The state of a
text_input()
.- focus()¶
Focuses the
text_input()
.Warning
If the state is currently in use, the method will fail.
- is_focused()¶
Returns whether the
text_input()
is currently focused or not.Warning
If the state is currently in use, the method will fail.
- Returns
Yes or no
- Return type
- move_cursor_to(position)¶
Moves the
TextInputCursor()
of theTextInput
to an arbitrary location.The result is measured in terms of graphems, not bytes or codepoints!
See also
Warning
If the state is currently in use, the method will fail.
- Parameters
position (int) – The new cursor position.
- move_cursor_to_end()¶
Moves the
TextInputCursor()
of theTextInput
to the end of the input text.Warning
If the state is currently in use, the method will fail.
- move_cursor_to_front()¶
Moves the
TextInputCursor()
of theTextInput
to the front of the input text.Warning
If the state is currently in use, the method will fail.
- selection(value)¶
Get the selected text.
Warning
If the state is currently in use, the method will fail.
- Parameters
value (str) – The current value of the
text_input()
.- Returns
The selected text. May be empty.
- Return type
- state(value)¶
Get the state of the
TextInputCursor()
.The result is measured in terms of graphems, not bytes or codepoints!
Warning
If the state is currently in use, the method will fail.
- Returns
int – The current cursor position when there’s no selection.
Tuple[int, int] – The selected text range.
- unfocus()¶
Unfocuses the
text_input()
.Warning
If the state is currently in use, the method will fail.