batgrl.gadgets.behaviors.grabbable#

Grabbable behavior for a gadget.

Classes

Grabbable(*[, is_grabbable, ptf_on_grab, ...])

Grabbable behavior for a gadget.

class batgrl.gadgets.behaviors.grabbable.Grabbable(*, is_grabbable: bool = True, ptf_on_grab: bool = False, mouse_button: Literal['left', 'middle', 'no_button', 'right'] = 'left', **kwargs)#

Bases: object

Grabbable behavior for a gadget.

Mouse down events that collide with the gadget will “grab” it, calling grab(). While grabbed, each mouse event will call grab_update() until the gadget is ungrabbed, i.e., a mouse up event is received (which calls ungrab()).

To customize grabbable behavior, implement any of grab(), grab_update(), or ungrab().

Parameters:
is_grabbablebool, default: True

Whether grabbable behavior is enabled.

ptf_on_grabbool, default: False

Whether the gadget will be pulled to front when grabbed.

mouse_buttonMouseButton, default: “left”

Mouse button used for grabbing.

Attributes:
is_grabbablebool

Whether grabbable behavior is enabled.

ptf_on_grabbool

Whether the gadget will be pulled to front when grabbed.

mouse_buttonMouseButton

Mouse button used for grabbing.

is_grabbedbool

Whether gadget is grabbed.

Methods

grab(mouse_event)

Grab the gadget.

ungrab(mouse_event)

Ungrab the gadget.

grab_update(mouse_event)

Update gadget with incoming mouse events while grabbed.

grab(mouse_event: MouseEvent)#

Grab gadget.

Parameters:
mouse_eventMouseEvent

The mouse event that grabbed the gadget.

grab_update(mouse_event: MouseEvent)#

Update grabbed gadget with incoming mouse event.

Parameters:
mouse_eventMouseEvent

The mouse event that updates the grabbed gadget.

property is_grabbed: bool#

Whether gadget is grabbed.

on_mouse(mouse_event)#

Determine if mouse event grabs or ungrabs gadget.

ungrab(mouse_event: MouseEvent)#

Ungrab gadget.

Parameters:
mouse_eventMouseEvent

The mouse event that ungrabbed the gadget.