0

I'm trying to restrict the handling of touch events for a UIView subclass to certain touch types, i.e. the pencil.

Of course I have read the classic question regarding a similar topic:

iOS - forward all touches through a view

In the discussion I found, that the touches of the event are added to the event at a later stage, which can easily be verified:

public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {

    let touches = event?.allTouches // This is always nil, touches are added later :-/

    return super.point(inside: point, with: event)
}

So it seems that hit testing can not be manipulated to solve my task… any other ideas?

Thanks!

  • what's the issue with `point(inside` ? if self is of a specific type return `super.point(inside: point, with: event)` else return false – Sandeep Bhandari May 19 '20 at 09:09
  • @SandeepBhandari – the issue is that here there is no way to determine the touch type causing the event here: event.allTouches is always nil (and that is by design), so how to find out the source device of the event? – Klaus Busse May 19 '20 at 10:08

0 Answers0