diff --git a/Memola/Canvas/View/Bridge/ViewController/CanvasViewController.swift b/Memola/Canvas/View/Bridge/ViewController/CanvasViewController.swift index 5c045d5..4aa65eb 100644 --- a/Memola/Canvas/View/Bridge/ViewController/CanvasViewController.swift +++ b/Memola/Canvas/View/Bridge/ViewController/CanvasViewController.swift @@ -48,7 +48,6 @@ final class CanvasViewController: Platform.ViewController { } #if os(macOS) - override func viewWillAppear() { super.viewWillAppear() resizeDocumentView() @@ -462,14 +461,12 @@ extension CanvasViewController { enablesDrawing = false enablesPhotoInsertion = true } - #if os(macOS) - #warning("TODO: implement for macos") - #else - scrollView.isScrollEnabled = enablesScrolling drawingView.isUserInteractionEnabled = enablesDrawing photoInsertGesture?.isEnabled = enablesPhotoInsertion - enablesDrawing ? drawingView.enableUserInteraction() : drawingView.disableUserInteraction() + #if os(iOS) + scrollView.isScrollEnabled = enablesScrolling #endif + enablesDrawing ? drawingView.enableUserInteraction() : drawingView.disableUserInteraction() } } @@ -483,14 +480,6 @@ extension CanvasViewController { #endif } - private func lockModeChanged(_ state: Bool) { - #if os(macOS) - #warning("TODO: implement for macos") - #else - scrollView.pinchGestureRecognizer?.isEnabled = !state - #endif - } - private func gridModeChanged(_ mode: GridMode) { drawingView.disableUserInteraction() renderer.setRedrawsGraphicRender() diff --git a/Memola/Canvas/View/Bridge/Views/DrawingView.swift b/Memola/Canvas/View/Bridge/Views/DrawingView.swift index 71833c2..135a598 100644 --- a/Memola/Canvas/View/Bridge/Views/DrawingView.swift +++ b/Memola/Canvas/View/Bridge/Views/DrawingView.swift @@ -21,6 +21,10 @@ final class DrawingView: Platform.View { private var lastDrawTime: CFTimeInterval = 0 private let minDrawInterval: CFTimeInterval = 1.0 / 60.0 + #if os(macOS) + var isUserInteractionEnabled: Bool = true + #endif + required init(tool: Tool, canvas: Canvas, history: History) { self.tool = tool self.canvas = canvas @@ -58,6 +62,10 @@ final class DrawingView: Platform.View { let point = CGPoint(x: pointInLeftBottomOrigin.x, y: bounds.height - pointInLeftBottomOrigin.y) touchEnded(at: point) } + + override func hitTest(_ point: NSPoint) -> NSView? { + isUserInteractionEnabled ? super.hitTest(point) : nil + } #else override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { !canvas.hasValidStroke