| ... | @@ -68,6 +68,7 @@ final class InkGesture: UIGestureRecognizer { | ... | @@ -68,6 +68,7 @@ final class InkGesture: UIGestureRecognizer { |
| 68 | } | 68 | } |
| 69 | | 69 | |
| 70 | override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) { | 70 | override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) { |
| | 71 | super.touchesBegan(touches, with: event) |
| 71 | for touch in touches { | 72 | for touch in touches { |
| 72 | if tracked == nil { | 73 | if tracked == nil { |
| 73 | tracked = touch | 74 | tracked = touch |
| ... | @@ -82,22 +83,26 @@ final class InkGesture: UIGestureRecognizer { | ... | @@ -82,22 +83,26 @@ final class InkGesture: UIGestureRecognizer { |
| 82 | } | 83 | } |
| 83 | | 84 | |
| 84 | override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent) { | 85 | override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent) { |
| | 86 | super.touchesMoved(touches, with: event) |
| 85 | guard let tracked, touches.contains(tracked) else { return } | 87 | guard let tracked, touches.contains(tracked) else { return } |
| 86 | points += (event.coalescedTouches(for: tracked) ?? [tracked]).map(sample) | 88 | points += (event.coalescedTouches(for: tracked) ?? [tracked]).map(sample) |
| 87 | state = .changed | 89 | state = .changed |
| 88 | } | 90 | } |
| 89 | | 91 | |
| 90 | override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent) { | 92 | override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent) { |
| | 93 | super.touchesEnded(touches, with: event) |
| 91 | guard let tracked, touches.contains(tracked) else { return } | 94 | guard let tracked, touches.contains(tracked) else { return } |
| 92 | points.append(sample(tracked)) | 95 | points.append(sample(tracked)) |
| 93 | state = .ended | 96 | state = .ended |
| 94 | } | 97 | } |
| 95 | | 98 | |
| 96 | override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent) { | 99 | override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent) { |
| | 100 | super.touchesCancelled(touches, with: event) |
| 97 | state = .cancelled | 101 | state = .cancelled |
| 98 | } | 102 | } |
| 99 | | 103 | |
| 100 | override func reset() { | 104 | override func reset() { |
| | 105 | super.reset() |
| 101 | tracked = nil | 106 | tracked = nil |
| 102 | points = [] | 107 | points = [] |
| 103 | } | 108 | } |