from typing import Optional
from gi.repository import Gtk
from gaphas.item import Item
from gaphas.tool.itemtool import handle_at_point, item_at_point
from gaphas.types import Pos
from gaphas.view import GtkView
def on_motion(ctrl, x, y):
view = ctrl.get_widget()
view.selection.hovered_item = find_item_at_point(view, (x, y))
def find_item_at_point(view: GtkView, pos: Pos) -> Optional[Item]:
item, handle = handle_at_point(view, pos)
return item or next(item_at_point(view, pos), None) # type: ignore[call-overload]