Have a look at the CanvasPicker class from the event_filter example.

Uwe