Previous topic

Events

Next topic

Position and Size

FocusΒΆ

GUI implements a focus like most other guis. The focus marks one Widget as active or selected. For example a TextInput will only be editable if it has the focus. The user can set the focus intuitively by simply clicking on a widget.

Since focus is a global attribute, its handled by GUI. Use set_focus() to give a widget the focus. The widget that has the focus is referenced in GUI.focused_widget but Widgets should just use their self.focused attribute to check whether they have the focus or not.

In addition to the default Widget Events focused and focus_lost, there are two events about focus sent by GUI:

  • new_focus (old_focused, new_focused)

    Focus changed from one Widget (old_focused) to another (new_focused).

  • focus_lost (old_focused)

    Focus was lost (old_focused is the previously focused Widget).

You can disable focus support of a class by setting the class attribute focusable to False. If a not focusable Widget is clicked, focus will be set to None.