batgrl.gadgets.behaviors.button_behavior#
Button behavior for a gadget.
Module Attributes
Button behavior states. |
Classes
|
Button behavior for a gadget. |
- class batgrl.gadgets.behaviors.button_behavior.ButtonBehavior(*, always_release: bool = False, **kwargs)#
Bases:
object
Button behavior for a gadget.
A button has four states: “normal”, “hover”, “down”, and “disallowed”.
When a button’s state changes one of the following methods are called: -
update_normal()
-update_hover()
-update_down()
-update_disallowed()
When a button is released, the
on_release()
method is called.- Parameters:
- always_releasebool, default: False
Whether a mouse up event outside the button will trigger it.
- Attributes:
- always_releasebool
Whether a mouse up event outside the button will trigger it.
button_state
ButtonStateCurrent button state.
Methods
on_release()
Triggered when a button is released.
update_normal()
Paint the normal state.
update_hover()
Paint the hover state.
update_down()
Paint the down state.
update_disallowed()
Paint the disallowed state.
- property button_state: Literal['normal', 'hover', 'down', 'disallowed']#
Current button state.
- on_add()#
Paint normal state on add.
- on_mouse(mouse_event) → bool | None#
Determine button state from mouse event.
- on_release()#
Triggered when button is released.
- update_disallowed()#
Paint the disallowed state.
- update_down()#
Paint the down state.
- update_hover()#
Paint the hover state.
- update_normal()#
Paint the normal state.
- batgrl.gadgets.behaviors.button_behavior.ButtonState#
Button behavior states.
alias of
Literal
[‘normal’, ‘hover’, ‘down’, ‘disallowed’]