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.


    Ui.ScrollView and touch events

    Pythonista
    scrollview
    2
    6
    4240
    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.
    • Phuket2
      Phuket2 last edited by

      Guys, would it be a correct assertion to say that it's not possible to get touch events from a scrollview?

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

        The views within scrollviews do get touch events. but if you start scrolling for a not swipe element, the swipe goes up to the scrollview. for instance, sliders within scrollviews work. buttons in scrollviews work, but if you wuickly start swiping on the button, the scrollview gets the touch, and the hutton does not get triggered. not sure about other custom touch elements.

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

          @JonB, thanks. That basically answers my question. With my VirtualView, I was feeling bad that if I wanted a click event so to speak on an item, I am creating a ui.Button and adding an action and an extra view. It feels bad doing it that way. It should be a pointinrect call with some coord translations (globaltolocal) or something like that. But I am taking advantage of many layers of code. There will be limitations.
          I really don't understand the overhead of creating the button etc... to capture the click. But I know it's 100% more than if I didn't need to do it at all.

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

            i think you are better off using Buttons, if you just want to handle clicks. Button touches are handled in objc code, the same way all other ios objects are handled( under the hood, a ui.Button is just a subclass of UIButton), so figure that is pretty well optimized. Rolling your own code means you are executing touch handling within python, which will be slower.

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

              @JonB , hmmm. I just tried. I put the touch_began and touch_ended in the cells view. Meaning, no rolling my own code. In the case where I just want to respond to a click over the entire cell, this seems a lot better option . But this is to use in the VirtualView. I think for normal requirements you wouldn't bother. In this case were you want the cells to be created as fast as possible and as little overhead as possible, this seems perfect.
              Also, it does not appear to clash with the scrolling. When scrolling, I am getting a touch_began but no touch_ended, which is perfect. I will play with it more and make sure it holds up. But it looks like it will.
              So unless I am haven't considered something, seems like a good solution.

              I did try it before, but I was trying to do something in the parent view of scrollview instead of the cell view. Makes sense to me now.

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

                Oh another benefit , I guess I get off the main thread.

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