• 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.

  • Using min() and max() simplifies keeping sprites in bounds...

    import scene class ButtonNode(scene.SpriteNode): def __init__(self, title, *args, **kwargs): scene.SpriteNode.__init__(self, 'pzl:Button1', *args, **kwargs) self.title = title scene.LabelNode(title, color='blue', font=('Avenir Next', 20), parent=self, position=(0, 0)) def touch_began(self, touch): sprite = self.parent.sprite x, y = sprite.position if self.title == '←': sprite.position = max(x - 20, 0), y elif self.title == '→': sprite.position = min(x + 20, self.parent.size.w), y elif self.title == '↓': sprite.position = x, max(y - 20, 0) elif self.title == '↑': sprite.position = x, min(y + 20, self.parent.size.h) class MyScene(scene.Scene): def setup(self): center = self.size/2 self.sprite = scene.SpriteNode('Dog_Face', parent=self, position=center) ButtonNode('←', parent=self, position=center - (300, 300)) ButtonNode('→', parent=self, position=center - (100, 300)) ButtonNode('↓', parent=self, position=center + (100, -300)) ButtonNode('↑', parent=self, position=center + (300, -300)) def touch_began(self, touch): for node in self.children: if touch.location in node.frame and hasattr(node, 'touch_began'): node.touch_began(touch) scene.run(MyScene())
  • @JonB , after a long afternoon of trying understand the side effects I was creating, I have decided to go a different way. It gets worse when trying to add functionality to the class, which is the main intent. I am not giving up. I just dont think its a viable solution. I know you did it in a limited context.

    I have thought of another way with just some wrapper functions. I am pretty sure i will be able to achieve almost all I wanted to do with a fraction of the code and side effects. Let's see 😱😳👍

Internal error.

Oops! Looks like something went wrong!