mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-07-09 14:25:18 +02:00
feat: add mouse touch event for stroke drawing
This commit is contained in:
@@ -38,7 +38,26 @@ class DrawingView: Platform.View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
#warning("TODO: to implement touch events")
|
override func mouseDown(with event: NSEvent) {
|
||||||
|
super.mouseDown(with: event)
|
||||||
|
let pointInLeftBottomOrigin = convert(event.locationInWindow, from: nil)
|
||||||
|
let point = CGPoint(x: pointInLeftBottomOrigin.x, y: bounds.height - pointInLeftBottomOrigin.y)
|
||||||
|
touchBegan(at: point)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func mouseDragged(with event: NSEvent) {
|
||||||
|
super.mouseDragged(with: event)
|
||||||
|
let pointInLeftBottomOrigin = convert(event.locationInWindow, from: nil)
|
||||||
|
let point = CGPoint(x: pointInLeftBottomOrigin.x, y: bounds.height - pointInLeftBottomOrigin.y)
|
||||||
|
touchMoved(to: point)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func mouseUp(with event: NSEvent) {
|
||||||
|
super.mouseUp(with: event)
|
||||||
|
let pointInLeftBottomOrigin = convert(event.locationInWindow, from: nil)
|
||||||
|
let point = CGPoint(x: pointInLeftBottomOrigin.x, y: bounds.height - pointInLeftBottomOrigin.y)
|
||||||
|
touchEnded(at: point)
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||||
!canvas.hasValidStroke
|
!canvas.hasValidStroke
|
||||||
|
|||||||
Reference in New Issue
Block a user