class documentation
class Keyboard:
Constructor: Keyboard(draw, input_manager, text_color, background_color, ...)
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 |
Set the list of words for auto-completion. |
| Method | callback |
Set the current save callback function. |
| Method | reset |
Resets the keyboard state |
| Method | response |
Set the response string. |
| Method | run |
Run the input manager, handle input, and draw the keyboard. |
| Method | set |
Set the save callback function. |
| Method | show |
Set whether the on-screen keyboard is shown. |
| Method | title |
Set the current title of the keyboard. |
| Constant | NUM |
Undocumented |
| Constant | ROW1 |
Undocumented |
| Constant | ROW2 |
Undocumented |
| Constant | ROW3 |
Undocumented |
| Constant | ROW4 |
Undocumented |
| Constant | ROW5 |
Undocumented |
| Constant | ROW |
Undocumented |
| Constant | ROWS |
Undocumented |
| Instance Variable | background |
Undocumented |
| Instance Variable | current |
Undocumented |
| Instance Variable | current |
Undocumented |
| Instance Variable | cursor |
Undocumented |
| Instance Variable | cursor |
Undocumented |
| Instance Variable | cursor |
Undocumented |
| Instance Variable | d |
Undocumented |
| Instance Variable | dpad |
Undocumented |
| Instance Variable | draw |
Undocumented |
| Instance Variable | input |
Undocumented |
| Instance Variable | is |
Undocumented |
| Instance Variable | is |
Undocumented |
| Instance Variable | is |
Undocumented |
| Instance Variable | is |
Undocumented |
| Instance Variable | is |
Undocumented |
| Instance Variable | just |
Undocumented |
| Instance Variable | KEY |
Undocumented |
| Instance Variable | key |
Undocumented |
| Instance Variable | KEY |
Undocumented |
| Instance Variable | KEY |
Undocumented |
| Instance Variable | KEY |
Undocumented |
| Instance Variable | keyboard |
Undocumented |
| Instance Variable | manual |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | on |
Undocumented |
| Instance Variable | selected |
Undocumented |
| Instance Variable | selected |
Undocumented |
| Instance Variable | size |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | text |
Undocumented |
| Instance Variable | TEXTBOX |
Undocumented |
| Instance Variable | title |
Undocumented |
| Property | auto |
Returns the list of words for auto-completion |
| Property | callback |
Returns the current save callback function |
| Property | is |
Returns whether the keyboard is finished |
| Property | keyboard |
Returns the keyboard width/width of the display |
| Property | response |
Returns the response string |
| Property | show |
Returns whether the on-screen keyboard is shown |
| Property | title |
Returns the current title of the keyboard |
| Method | _apply |
Apply an auto-complete suggestion to the current response. |
| Method | _auto |
Gets the top auto-complete suggestion based on current response |
| Method | _auto |
Gets auto-complete suggestions based on current response |
| Method | _build |
Set each key's (x, y, width, height) rectangle. |
| Method | _default |
Returns a default list of words for auto-completion |
| Method | _draw |
Draw a specific key on the keyboard. |
| Method | _draw |
Draws the entire keyboard |
| Method | _draw |
Draws auto-complete suggestions based on keyboard visibility |
| Method | _draw |
Draws the text box that displays the current saved response |
| Method | _handle |
Handles directional input and key selection |
| Method | _handle |
Press the key under the touch point. True if the touch was used. |
| Method | _key |
Return the (row, col) under a touch point, or None. |
| Method | _process |
Processes the currently selected key press |
| Method | _set |
Sets the words for auto-completion |
| Method | _set |
Set the cursor position on the keyboard. |
| Instance Variable | _auto |
Undocumented |
| Instance Variable | _auto |
Undocumented |
| Instance Variable | _auto |
Undocumented |
| Instance Variable | _is |
Undocumented |
| Instance Variable | _key |
Undocumented |
| Instance Variable | _response |
Undocumented |
| Instance Variable | _show |
Undocumented |
| Instance Variable | _touch |
Undocumented |
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:Draw | Drawing context for rendering the keyboard. |
| input | Input manager to handle button presses. |
textint | Color for the text on keys and textbox. Defaults to 0xFFFF. |
backgroundint | Background color for keys and textbox. Defaults to 0x0000. |
selectedint | Color for the selected key highlight. Defaults to 0x001F. |
oncallable | Optional callback called when "Save" is pressed. Defaults to None. |
Run the input manager, handle input, and draw the keyboard.
| 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 stopped. |
Apply an auto-complete suggestion to the current response.
| Parameters | |
suggestionstr | The suggestion to apply. |
Draw a specific key on the keyboard.
| Parameters | |
row:int | The key row index. |
col:int | The key column index. |
isbool | Whether the key is currently selected. |
Return the (row, col) under a touch point, or None.
| Parameters | |
x:int | The touch X coordinate. |
y:int | The touch Y coordinate. |
| Returns | |
tuple or None | The (row, col) of the key, or None if not on a key. |