class documentation

A simple on-screen keyboard class for a GUI.

Method __del__ Clean up keyboard resources.
Method __init__ Initialize the keyboard with drawing context and input manager.
Method auto_complete_words.setter Set the list of words for auto-completion.
Method callback.setter Set the current save callback function.
Method reset Resets the keyboard state
Method response.setter Set the response string.
Method run Run the input manager, handle input, and draw the keyboard.
Method set_save_callback Set the save callback function.
Method show_keyboard.setter Set whether the on-screen keyboard is shown.
Method title.setter Set the current title of the keyboard.
Constant NUM_ROWS Undocumented
Constant ROW1 Undocumented
Constant ROW2 Undocumented
Constant ROW3 Undocumented
Constant ROW4 Undocumented
Constant ROW5 Undocumented
Constant ROW_SIZES Undocumented
Constant ROWS Undocumented
Instance Variable background_color Undocumented
Instance Variable current_key Undocumented
Instance Variable current_title Undocumented
Instance Variable cursor Undocumented
Instance Variable cursor_col Undocumented
Instance Variable cursor_row Undocumented
Instance Variable d_pad Undocumented
Instance Variable dpad_input Undocumented
Instance Variable draw Undocumented
Instance Variable input_manager Undocumented
Instance Variable is_caps_lock_on Undocumented
Instance Variable is_in_textbox Undocumented
Instance Variable is_manual_shift Undocumented
Instance Variable is_save_pressed Undocumented
Instance Variable is_shift_pressed Undocumented
Instance Variable just_stopped Undocumented
Instance Variable KEY_HEIGHT Undocumented
Instance Variable key_mappings Undocumented
Instance Variable KEY_MARGIN Undocumented
Instance Variable KEY_SPACING Undocumented
Instance Variable KEY_WIDTH Undocumented
Instance Variable keyboard_height Undocumented
Instance Variable manual_keys Undocumented
Instance Variable max_chars_per_line Undocumented
Instance Variable max_lines Undocumented
Instance Variable on_save_callback Undocumented
Instance Variable selected_color Undocumented
Instance Variable selected_suggestion_index Undocumented
Instance Variable size_vec Undocumented
Instance Variable text_border_pos Undocumented
Instance Variable text_border_size Undocumented
Instance Variable text_box_pos_size Undocumented
Instance Variable text_box_pos_vec Undocumented
Instance Variable text_color Undocumented
Instance Variable text_cursor_position Undocumented
Instance Variable text_cursor_x Undocumented
Instance Variable text_cursor_y Undocumented
Instance Variable text_scroll_x Undocumented
Instance Variable text_vec Undocumented
Instance Variable TEXTBOX_HEIGHT Undocumented
Instance Variable title Returns the current title of the keyboard
Instance Variable title_vec Undocumented
Property auto_complete_words Returns the list of words for auto-completion
Property callback Returns the current save callback function
Property is_finished Returns whether the keyboard is finished
Property keyboard_width Returns the keyboard width/width of the display
Property response Returns the response string
Property show_keyboard Returns whether the on-screen keyboard is shown
Method _apply_suggestion Apply an auto-complete suggestion to the current response.
Method _auto_complete_suggestion Gets the top auto-complete suggestion based on current response
Method _auto_complete_suggestions Gets auto-complete suggestions based on current response
Method _build_key_rects Fit labels and borders inside disjoint drawing and touch rectangles.
Method _default_words Returns a default list of words for auto-completion
Method _draw_key Draw a specific key on the keyboard.
Method _draw_keyboard Draws the entire keyboard
Method _draw_suggestions Draws auto-complete suggestions based on keyboard visibility
Method _draw_textbox Draws the text box that displays the current saved response
Method _fit_text Keep a single line within the available pixel width.
Method _handle_input Handles directional input and key selection.
Method _handle_touch_input Press the key under the touch point. True if the touch was used.
Method _key_at_point Return the (row, col) under a touch point, or None.
Method _key_label Return the current key label, using compact modifier icons.
Method _key_widths Undocumented
Method _process_key_press Processes the currently selected key press
Method _set_auto_complete_words Sets the words for auto-completion
Method _set_cursor_position Set the cursor position on the keyboard.
Instance Variable _auto_complete Undocumented
Instance Variable _auto_complete_words Undocumented
Instance Variable _auto_complete_words_set Undocumented
Instance Variable _display_title Undocumented
Instance Variable _is_flipper Undocumented
Instance Variable _key_font Undocumented
Instance Variable _key_rects Undocumented
Instance Variable _keys_y Undocumented
Instance Variable _layout_height Undocumented
Instance Variable _layout_width Undocumented
Instance Variable _layout_x Undocumented
Instance Variable _layout_y Undocumented
Instance Variable _response Undocumented
Instance Variable _rotated Undocumented
Instance Variable _show_keyboard Undocumented
Instance Variable _suggestion_y Undocumented
Instance Variable _text_y Undocumented
Instance Variable _touch_enabled Undocumented
def __del__(self):

Clean up keyboard resources.

def __init__(self, draw, input_manager, text_color: int = 65535, background_color: int = 0, selected_color: int = 31, on_save_callback: callable = None):

Initialize the keyboard with drawing context and input manager.

Parameters
draw:DrawDrawing context for rendering the keyboard.
input_managerInput manager to handle button presses.
text_color:intColor for the text on keys and textbox. Defaults to 0xFFFF.
background_color:intBackground color for keys and textbox. Defaults to 0x0000.
selected_color:intColor for the selected key highlight. Defaults to 0x001F.
on_save_callback:callableOptional callback called when "Save" is pressed. Defaults to None.
def auto_complete_words(self, value: list[str]):

Set the list of words for auto-completion.

Parameters
value:list[str]The new word list.
def callback(self, value: callable):

Set the current save callback function.

Parameters
value:callableThe new callback function.
def reset(self):

Resets the keyboard state

def response(self, value: str):

Set the response string.

Parameters
value:strThe new response string.
def run(self, swap: bool = True, force: bool = False, max_characters: int = 0) -> bool:

Run the input manager, handle input, and draw the keyboard.

Parameters
swap:boolWhether to swap the display buffer. Defaults to True.
force:boolWhether to force a redraw. Defaults to False.
max_characters:intThe maximum number of characters allowed in the response. 0 means no limit. Defaults to 0.
Returns
boolTrue while running, False when stopped.
def set_save_callback(self, callback: callable):

Set the save callback function.

Parameters
callback:callableThe callback to call on save.
def show_keyboard(self, value: bool):

Set whether the on-screen keyboard is shown.

Parameters
value:boolTrue to show the keyboard.
def title(self, value: str):

Set the current title of the keyboard.

Parameters
value:strThe new title.
NUM_ROWS: int =

Undocumented

Value
5
ROW1 =

Undocumented

Value
[KeyLayout('1', '!', 1),
 KeyLayout('2', '@', 1),
 KeyLayout('3', '#', 1),
 KeyLayout('4', '$', 1),
 KeyLayout('5', '%', 1),
 KeyLayout('6', '^', 1),
 KeyLayout('7', '&', 1),
...
ROW2 =

Undocumented

Value
[KeyLayout('q', 'Q', 1),
 KeyLayout('w', 'W', 1),
 KeyLayout('e', 'E', 1),
 KeyLayout('r', 'R', 1),
 KeyLayout('t', 'T', 1),
 KeyLayout('y', 'Y', 1),
 KeyLayout('u', 'U', 1),
...
ROW3 =

Undocumented

Value
[KeyLayout('\x01', '\x01', 1),
 KeyLayout('a', 'A', 1),
 KeyLayout('s', 'S', 1),
 KeyLayout('d', 'D', 1),
 KeyLayout('f', 'F', 1),
 KeyLayout('g', 'G', 1),
 KeyLayout('h', 'H', 1),
...
ROW4 =

Undocumented

Value
[KeyLayout('\x02', '\x02', 1),
 KeyLayout('z', 'Z', 1),
 KeyLayout('x', 'X', 1),
 KeyLayout('c', 'C', 1),
 KeyLayout('v', 'V', 1),
 KeyLayout('b', 'B', 1),
 KeyLayout('n', 'N', 1),
...
ROW5 =

Undocumented

Value
[KeyLayout(' ', ' ', 6), KeyLayout('\x03', '\x03', 2)]
ROW_SIZES: list[int] =

Undocumented

Value
[13, 13, 13, 13, 2]
ROWS =

Undocumented

Value
[ROW1, ROW2, ROW3, ROW4, ROW5]
background_color =

Undocumented

current_key: int =

Undocumented

current_title =

Undocumented

cursor =

Undocumented

cursor_col =

Undocumented

cursor_row =

Undocumented

d_pad: dict =

Undocumented

dpad_input: int =

Undocumented

draw =

Undocumented

input_manager =

Undocumented

is_caps_lock_on: bool =

Undocumented

is_in_textbox: bool =

Undocumented

is_manual_shift: bool =

Undocumented

is_save_pressed: bool =

Undocumented

is_shift_pressed =

Undocumented

just_stopped: bool =

Undocumented

KEY_HEIGHT =

Undocumented

key_mappings: dict =

Undocumented

KEY_MARGIN =

Undocumented

KEY_SPACING: int =

Undocumented

KEY_WIDTH =

Undocumented

keyboard_height =

Undocumented

manual_keys: dict =

Undocumented

max_chars_per_line =

Undocumented

max_lines =

Undocumented

on_save_callback =

Undocumented

selected_color =

Undocumented

selected_suggestion_index: int =

Undocumented

size_vec =

Undocumented

text_border_pos =

Undocumented

text_border_size =

Undocumented

text_box_pos_size =

Undocumented

text_box_pos_vec =

Undocumented

text_color =

Undocumented

text_cursor_position =

Undocumented

text_cursor_x: int =

Undocumented

text_cursor_y: int =

Undocumented

text_scroll_x =

Undocumented

text_vec =

Undocumented

TEXTBOX_HEIGHT =

Undocumented

@property
title: str =

Returns the current title of the keyboard

title_vec =

Undocumented

@property
auto_complete_words: list[str] =

Returns the list of words for auto-completion

@property
callback: callable =

Returns the current save callback function

@property
is_finished: bool =

Returns whether the keyboard is finished

@property
keyboard_width: int =

Returns the keyboard width/width of the display

@property
response: str =

Returns the response string

@property
show_keyboard: bool =

Returns whether the on-screen keyboard is shown

def _apply_suggestion(self, suggestion_text: str):

Apply an auto-complete suggestion to the current response.

Parameters
suggestion_text:strThe suggestion to apply.
def _auto_complete_suggestion(self) -> str:

Gets the top auto-complete suggestion based on current response

def _auto_complete_suggestions(self) -> tuple:

Gets auto-complete suggestions based on current response

def _build_key_rects(self) -> list:

Fit labels and borders inside disjoint drawing and touch rectangles.

def _default_words(self) -> list[str]:

Returns a default list of words for auto-completion

def _draw_key(self, row: int, col: int, is_selected: bool):

Draw a specific key on the keyboard.

Parameters
row:intThe key row index.
col:intThe key column index.
is_selected:boolWhether the key is currently selected.
def _draw_keyboard(self):

Draws the entire keyboard

def _draw_suggestions(self):

Draws auto-complete suggestions based on keyboard visibility

def _draw_textbox(self):

Draws the text box that displays the current saved response

def _fit_text(self, text: str, width: int) -> str:

Keep a single line within the available pixel width.

def _handle_input(self, max_characters: int = 0):

Handles directional input and key selection.

Parameters
max_characters:intThe maximum number of characters allowed in the response. 0 means no limit.
def _handle_touch_input(self) -> bool:

Press the key under the touch point. True if the touch was used.

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

Return the (row, col) under a touch point, or None.

Parameters
x:intThe touch X coordinate.
y:intThe touch Y coordinate.
Returns
tuple or NoneThe (row, col) of the key, or None if not on a key.
def _key_label(self, row: int, col: int) -> str:

Return the current key label, using compact modifier icons.

def _key_widths(self, row: int, unit: int) -> list:

Undocumented

def _process_key_press(self):

Processes the currently selected key press

def _set_auto_complete_words(self):

Sets the words for auto-completion

def _set_cursor_position(self, row: int, col: int):

Set the cursor position on the keyboard.

Parameters
row:intThe row to move to.
col:intThe column to move to.
_auto_complete =

Undocumented

_auto_complete_words =

Undocumented

_auto_complete_words_set: bool =

Undocumented

_display_title =

Undocumented

_is_flipper =

Undocumented

_key_font =

Undocumented

_key_rects =

Undocumented

_keys_y =

Undocumented

_layout_height =

Undocumented

_layout_width =

Undocumented

_layout_x =

Undocumented

_layout_y =

Undocumented

_response =

Undocumented

_rotated =

Undocumented

_show_keyboard =

Undocumented

_suggestion_y =

Undocumented

_text_y =

Undocumented

_touch_enabled =

Undocumented