pressure / apple pencil data in touch event object?
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!
ϵ( 'Θ' )϶
It's relatively easy to convert a
ui.Touchobject to an Objective-C
UITouchto 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')
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!
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...
@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.