@mikael in my use case, I'm actually making a Gestures instance per-custom-widget. Since each of my widgets can have 2 or 3 gestures, it is simpler to just let each one have its own Gestures instance and install the various recognizers on each one. Gestures isn't particularly heavyweight, especially without the internal ui.Button instance, and then I don't need any global tracking of who has gestures installed, since when the widget goes away, it takes the gestures instance with it.
Creating a little handler method in the gesture delegate class, which can be attached to a gesture recognizer is as simple as:
...existing gesture delegate definition...
def handleGesture_(_self, _cmd, recognizer):
delegate = objc_util.ObjCInstance(_self)
if not delegate: return
recognizer = objc_util.ObjCInstance(recognizer)
if not recognizer: return
gestures = delegate._gestures()
if not gestures: return
methods = [...
Then, where you make the recognizers, instead of the whole button action thing, with all the associated bookkeeping:
recognizer = \