omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    incorrect touch locations

    Pythonista
    2
    4
    1938
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JonB
      JonB last edited by

      I believe this is a new bug:

      import ui,console
      class Touchy(ui.View):
      	def __init__(self,*args,**kwargs):
      		ui.View.__init__(self,*args,**kwargs)
      		self.add_subview(ui.View(frame=(300,300,44,44),bg_color='red'))
      	def touch_began(self,touch):
      		console.hud_alert('{p.x},{p.y}'.format(p=touch.location))
      v=Touchy(frame=(0,0,600,600)).present('sheet')
      

      Touch near but not on the red square.
      Result, a value near 300,300, as expected.
      Now touch the red square:
      result is touch location relative to the subview coords, rather than the custom view.

      I believe the way it used to work is that a Touch location was the location relative to the custom view which implemented the touch methods. This makes more sense, since a Touch does not contain any info about which subview was touched.

      As is, it is impossible to know where you actually touched, if implementing touch on a View subclass which has subviews which are vanilla View's.
      I am pretty sure this used to work properly, but I'm not sure.

      1 Reply Last reply Reply Quote 2
      • mikael
        mikael last edited by

        Interesting, I did not know you get the touches from the "on top" vanilla view at all.

        But regardless, does this behavior change if you make the red square not touch enabled?

        1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by

          unfortunately, a longstanding bug is that there is no way to set touch_enabled=False for a vanilla View. It stays True.

          The way I think it is supposed to work, if a view does not implement touch, the touch events should trickle up to the container, etc. But touches that trickle up should be in the frame of whoever is handling the touch I think.

          1 Reply Last reply Reply Quote 1
          • mikael
            mikael last edited by

            Touch handling really seems to be the most underdeveloped area in the ui module. I find myself using various workarounds for the simplest things. And bugs do not help, of course.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors