Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Help calling "addTarget:action:forControlEvents:" from objc_util
-
I guess I'm trying to understand the end goal. This is for some sort of debugging or logging purpose? A prank keylogger app?
Anything that has an python action or delegate includes a sender argument that gives you access to the item being touched, so you could use a decorator on those methods which handles the logging...
One approach would be to add a gesture recognizer on the application keyWindow, that does not cancel touch events.
https://stackoverflow.com/questions/8444184/listen-to-all-touch-events-in-an-ios-app
-
The use case is a little complicated, and very task-specific:
- app is constantly listening for incoming messages
- manipulating controls in the view sends outgoing messages
- some incoming messages will try to set the value of a control being manipulated
- this leads to "fighting" between the user and the system
- knowing which control or controls are being interacted with, we can filter the incoming messages so they don't attempt to set controls actively being manipulated, effectively "debouncing" the signal
I like the idea of a transparent layer...but I wanted to be more specific about what I considered "manipulating" the control...with this, I can say exactly what I consider to be user interaction for these purposes.
Anyway, I am using the sender argument coming from the addTarget_action_forControlEvents() call, which is how I'm keying which controls are marked active. For my purposes it is working.Unfortunately, it seems like the various Pythonista-wrapped UIControls have different ways, or sometimes no way, of getting access to the actual UIControl instance they wrap, which makes it a little complicated to call the addTarget_ objectiveC method to install the monitor.