From 6ad9218c1373f6a4c2f79e59ee88bf1b05162f47 Mon Sep 17 00:00:00 2001 From: Xyct <87l46110@gmail.com> Date: Tue, 16 May 2023 22:42:25 +0800 Subject: [PATCH] fix draggable button associate mouse cursor (#114) --- AKPlugin.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AKPlugin.swift b/AKPlugin.swift index ee9e72b1..13f27c1b 100644 --- a/AKPlugin.swift +++ b/AKPlugin.swift @@ -38,9 +38,10 @@ class AKPlugin: NSObject, Plugin { } var cmdPressed: Bool = false - + var cursorHideLevel = 0 func hideCursor() { NSCursor.hide() + cursorHideLevel += 1 CGAssociateMouseAndMouseCursorPosition(0) warpCursor() } @@ -54,7 +55,10 @@ class AKPlugin: NSObject, Plugin { func unhideCursor() { NSCursor.unhide() - CGAssociateMouseAndMouseCursorPosition(1) + cursorHideLevel -= 1 + if cursorHideLevel <= 0 { + CGAssociateMouseAndMouseCursorPosition(1) + } } func terminateApplication() {