class documentation
A search bar class with text input and search functionality.
| Method | __del__ |
Destructor to ensure cleanup on object deletion. |
| Method | __init__ |
Initialize the SearchBar with a view manager, search items, and styling. |
| Method | reset |
Resets the search bar state. |
| Method | run |
Run the input manager, handle input, and draw the search bar. |
| Instance Variable | draw |
Undocumented |
| Instance Variable | input |
Undocumented |
| Instance Variable | is |
Undocumented |
| Instance Variable | items |
Undocumented |
| Instance Variable | just |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | selected |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | text |
Undocumented |
| Property | is |
Returns whether the search bar is finished (an item was selected). |
| Property | results |
Get the current list of matching items. |
| Property | selected |
Get the currently highlighted (or clicked) matching item, or None. |
| Property | text |
Get the current text in the search bar. |
| Method | _compute |
Precompute the hit-test rectangles for the filtered items. |
| Method | _delete |
Delete the character before the cursor and re-filter the items. |
| Method | _draw |
Draw the search bar text box and the matching items. |
| Method | _draw |
Draw the matching items in columns below the text box. |
| Method | _draw |
Draw the text input box, the current text, and the cursor. |
| Method | _handle |
Handles character entry, navigation, and item selection. |
| Method | _handle |
Handle a touch tap. True if the touch was consumed. |
| Method | _item |
Return the index of the item under a touch point, or None. |
| Method | _move |
Move the text cursor left or right. |
| Method | _move |
Move the item highlight up or down. |
| Method | _select |
Click an item: set the save flag and signal that we are done. |
| Method | _type |
Insert a character at the cursor position and re-filter the items. |
| Method | _update |
Filter the item list based on the current search text. |
| Instance Variable | _background |
Undocumented |
| Instance Variable | _current |
Undocumented |
| Instance Variable | _cursor |
Undocumented |
| Instance Variable | _dpad |
Undocumented |
| Instance Variable | _filtered |
Undocumented |
| Instance Variable | _item |
Undocumented |
| Instance Variable | _margin |
Undocumented |
| Instance Variable | _margin |
Undocumented |
| Instance Variable | _num |
Undocumented |
| Instance Variable | _results |
Undocumented |
| Instance Variable | _results |
Undocumented |
| Instance Variable | _row |
Undocumented |
| Instance Variable | _selected |
Undocumented |
| Instance Variable | _size |
Undocumented |
| Instance Variable | _text |
Undocumented |
| Instance Variable | _text |
Undocumented |
| Instance Variable | _touch |
Undocumented |
| Instance Variable | _view |
Undocumented |
def __init__(self, view_manager, items:
list, size=None, text_color: int = 65535, background_color: int = 0, selected_color: int = 31):
¶
Initialize the SearchBar with a view manager, search items, and styling.
Positions and sizes derive from the screen size when size is None.
| Parameters | |
viewViewManager | The view manager context. |
items:list | The items to search through. |
size:Vector | The size of the search bar. Defaults to None (screen size). |
textint | The text color. Defaults to 0xFFFF. |
backgroundint | The background color. Defaults to 0x0000. |
selectedint | The selected item color. Defaults to 0x001F. |
Run the input manager, handle input, and draw the search bar.
| Parameters | |
swap:bool | Whether to swap the display buffer. Defaults to True. |
force:bool | Whether to force a redraw. Defaults to False. |
| Returns | |
bool | True while running, False when done. |
Return the index of the item under a touch point, or None.
| Parameters | |
x:int | The touch X coordinate. |
y:int | The touch Y coordinate. |
| Returns | |
int or None | The index of the item, or None if not on an item. |
Click an item: set the save flag and signal that we are done.
| Parameters | |
index:int | The index of the item to select. |