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.


    pressure / apple pencil data in touch event object?

    Pythonista
    4
    5
    5079
    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.
    • artlanguagecode
      artlanguagecode last edited by

      With the current version of Pythonista, is it possible to get more data from the touch events? For example, I know there has been a little discussion in JavaScript-land about being able to grab a pressure property for 3D touch or Apple Pencil, and I'm wondering if maybe the info can just be grabbed using objc_util, or if since we're dealing with an event here, it isn't as easy as that.

      Of course, that leads to the feature request part of this, which is to make it even easier and to include grabbing pressure (and even tilt, to be super slick!) data from Apple Pencil within Pythonista...

      ...but in the meantime, if anyone has gotten this to work or has any suggestions on how to get this to work via objc_util or some other method that I haven't yet considered, I'm all ears!

      ϵ( 'Θ' )϶

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

        It's relatively easy to convert a ui.Touch object to an Objective-C UITouch to get additional properties of the touch. Here's a very simple example (not tested with Apple Pencil, but I think it should behave the same as 3D Touch on an iPhone 6s):

        import ui
        from objc_util import ObjCInstance
        
        class MyView (ui.View):
        	def touch_moved(self, touch):
        		ui_touch = ObjCInstance(touch)
        		force = ui_touch.force()
        		# To keep it simple, just show the force in the view's title bar:
        		self.name = 'Force: %0.2f' % (force,)
        
        v = MyView(frame=(0, 0, 320, 320))
        v.present('sheet')
        
        1 Reply Last reply Reply Quote 4
        • artlanguagecode
          artlanguagecode last edited by

          You probably get tired of people telling you that you're awesome, but... you're awesome.

          Thanks for such a clear and simple example! Worked great with the Apple Pencil, just as you expected!

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

            Perhaps a very very late reaction.. but... I just bought an iPad pro 12’’ with Apple pencil and came up with the same question because I am working towards an application that enables you to draw musical scores. The ‘Pencil Script’ works indeed and my God what a possibilities! Hands-off Pythonista...

            mikael 1 Reply Last reply Reply Quote 0
            • mikael
              mikael @lenoirmind last edited by

              @lenoirmind, note that the azimuth properties are there as well, in case you want to do something with the direction the pencil leans/points to.

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