edifice.use_hover#

edifice.use_hover()[source]#

Hook to track mouse hovering.

Use this hook to track if the mouse is hovering over a QtWidgetElement.

use_hover#
hover, on_mouse_enter, on_mouse_leave = use_hover()

with VBoxView(
    on_mouse_enter=on_mouse_enter,
    on_mouse_leave=on_mouse_leave,
    style={"background-color": "green"} if hover else {},
):
    if hover:
        Label(text="hovering")

The on_mouse_enter and on_mouse_leave functions can be passed to more than one QtWidgetElement.

Returns:

  1. bool

    True if the mouse is hovering over the QtWidgetElement, False otherwise.

  2. Callable[[QtGui.QMouseEvent], None]

    Pass this function to the on_mouse_enter prop of the QtWidgetElement

  3. Callable[[QtGui.QMouseEvent], None]

    Pass this function to the on_mouse_leave prop of the QtWidgetElement.

Return type:

A tuple of three values