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_manager Undocumented
Instance Variable is_save_pressed Undocumented
Instance Variable items Undocumented
Instance Variable just_stopped Undocumented
Instance Variable max_chars_per_line Undocumented
Instance Variable max_lines Undocumented
Instance Variable selected_color Undocumented
Instance Variable text_box_pos_size Undocumented
Instance Variable text_box_pos_vec Undocumented
Property is_finished Returns whether the search bar is finished (an item was selected).
Property results Get the current list of matching items.
Property selected_item Get the currently highlighted (or clicked) matching item, or None.
Property text Get the current text in the search bar.
Method _compute_item_rects Precompute the hit-test rectangles for the filtered items.
Method _delete_char 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_results Draw the matching items in columns below the text box.
Method _draw_textbox Draw the text input box, the current text, and the cursor.
Method _handle_input Handles character entry, navigation, and item selection.
Method _handle_touch_input Handle a touch tap. True if the touch was consumed.
Method _item_at_point Return the index of the item under a touch point, or None.
Method _move_cursor Move the text cursor left or right.
Method _move_selection Move the item highlight up or down.
Method _select_item Click an item: set the save flag and signal that we are done.
Method _type_char Insert a character at the cursor position and re-filter the items.
Method _update_filter Filter the item list based on the current search text.
Instance Variable _background_color Undocumented
Instance Variable _current_text Undocumented
Instance Variable _cursor Undocumented
Instance Variable _dpad_input Undocumented
Instance Variable _filtered_items Undocumented
Instance Variable _item_rects Undocumented
Instance Variable _margin_x Undocumented
Instance Variable _margin_y Undocumented
Instance Variable _num_columns Undocumented
Instance Variable _results_height Undocumented
Instance Variable _results_top Undocumented
Instance Variable _row_height Undocumented
Instance Variable _selected_index Undocumented
Instance Variable _size Undocumented
Instance Variable _text_box_height Undocumented
Instance Variable _text_color Undocumented
Instance Variable _touch_enabled Undocumented
Instance Variable _view_manager Undocumented
def __del__(self):

Destructor to ensure cleanup on object deletion.

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
view_manager:ViewManagerThe view manager context.
items:listThe items to search through.
size:VectorThe size of the search bar. Defaults to None (screen size).
text_color:intThe text color. Defaults to 0xFFFF.
background_color:intThe background color. Defaults to 0x0000.
selected_color:intThe selected item color. Defaults to 0x001F.
def reset(self):

Resets the search bar state.

def run(self, swap: bool = True, force: bool = False) -> bool:

Run the input manager, handle input, and draw the search bar.

Parameters
swap:boolWhether to swap the display buffer. Defaults to True.
force:boolWhether to force a redraw. Defaults to False.
Returns
boolTrue while running, False when done.
draw =

Undocumented

input_manager =

Undocumented

is_save_pressed: bool =

Undocumented

items: list =

Undocumented

just_stopped: bool =

Undocumented

max_chars_per_line =

Undocumented

max_lines: int =

Undocumented

selected_color =

Undocumented

text_box_pos_size =

Undocumented

text_box_pos_vec =

Undocumented

@property
is_finished: bool =

Returns whether the search bar is finished (an item was selected).

@property
results: list =

Get the current list of matching items.

@property
selected_item =

Get the currently highlighted (or clicked) matching item, or None.

@property
text: str =

Get the current text in the search bar.

def _compute_item_rects(self):

Precompute the hit-test rectangles for the filtered items.

def _delete_char(self):

Delete the character before the cursor and re-filter the items.

def _draw(self):

Draw the search bar text box and the matching items.

def _draw_results(self):

Draw the matching items in columns below the text box.

def _draw_textbox(self):

Draw the text input box, the current text, and the cursor.

def _handle_input(self):

Handles character entry, navigation, and item selection.

def _handle_touch_input(self) -> bool:

Handle a touch tap. True if the touch was consumed.

def _item_at_point(self, x: int, y: int):

Return the index of the item under a touch point, or None.

Parameters
x:intThe touch X coordinate.
y:intThe touch Y coordinate.
Returns
int or NoneThe index of the item, or None if not on an item.
def _move_cursor(self, delta: int):

Move the text cursor left or right.

Parameters
delta:intThe number of positions to move.
def _move_selection(self, delta: int):

Move the item highlight up or down.

Parameters
delta:intThe number of positions to move.
def _select_item(self, index: int):

Click an item: set the save flag and signal that we are done.

Parameters
index:intThe index of the item to select.
def _type_char(self, char: str):

Insert a character at the cursor position and re-filter the items.

Parameters
char:strThe character to insert.
def _update_filter(self):

Filter the item list based on the current search text.

_background_color =

Undocumented

_current_text =

Undocumented

_cursor =

Undocumented

_dpad_input =

Undocumented

_filtered_items =

Undocumented

_item_rects: list =

Undocumented

_margin_x =

Undocumented

_margin_y =

Undocumented

_num_columns =

Undocumented

_results_height =

Undocumented

_results_top =

Undocumented

_row_height =

Undocumented

_selected_index =

Undocumented

_size =

Undocumented

_text_box_height =

Undocumented

_text_color =

Undocumented

_touch_enabled =

Undocumented

_view_manager =

Undocumented