Interfaces

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.

text

class SelectableText
_text = ''

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.

_text_offset = 0

The offset in pixels from the left side of the widget’s rect to the left edge of the text.

_text_pos = 0

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.

_select = None

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.

_chars = ((0, 0),)

Tuple containing (pos, width) tuples representing the position and size of each character when rendered. Automatically generated by _calc_chars().

_blink

Always return False when a selection is made.

_select_fix()

Returns the selection area corrected, so if the selection is right-to-left it returns the positions reversed.

_calc_chars()

Calculates the position and size of each character. Stores the results in self._chars as a tuple of (pos, width) tuples.

_mouse_cursor(mouse_pos)

Return the text cursor position of the mouse.

_update_select_text(time)

Update text stuff for selectable text.

Should be called from widget’s update() method.

_event_select_text(event)

Handles events for selectable text.

Call from widget’s _event() method.

_update_modify_text(time)

Update text stuff for editable text (e.g. input box).

Should be called from widget’s update() method.

_event_modify_text(event)

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_selection()

Delete the current selection of text.

_draw_selection(image, y, height)

Draw selection onto image. Does nothing if no selection.

_cursor_pos

The cursor position in characters. Will ensure cursor is always in valid location when set.

Table Of Contents

Previous topic

Developer documentation

Next topic

Menu Format