Interface classes that can be used to implement particular intefaces. Should use multiple inheritance to inherit from the base widget and any needed interface classes.
The current text. For normal selectable text, this should be a string. For editable text, this should be a list containing each different character as a separate item.
The offset in pixels from the left side of the widget’s rect to the left edge of the text.
Should always be initially set to _text_offset. Used internally.
Always return False when a selection is made.
True if the cursor should be drawn this frame.
Index of starting position for current selection. None if no current selection. Combined with _cursor_pos defines the selection. Use _select_fix() if you need the current selection area.
Tuple containing (pos, width) tuples representing the position and size of each character when rendered. Automatically generated by _calc_chars().
Always return False when a selection is made.
Returns the selection area corrected, so if the selection is right-to-left it returns the positions reversed.
Calculates the position and size of each character. Stores the results in self._chars as a tuple of (pos, width) tuples.
Return the text cursor position of the mouse.
Update text stuff for selectable text.
Should be called from widget’s update() method.
Handles events for selectable text.
Call from widget’s _event() method.
Update text stuff for editable text (e.g. input box).
Should be called from widget’s update() method.
Handles events for editable text (e.g. input box).
Should be called from widget’s _event() method. Will typically be used alongside _event_select_text().
Delete the current selection of text.
Draw selection onto image. Does nothing if no selection.
The cursor position in characters. Will ensure cursor is always in valid location when set.