Skip to content

Commit

Permalink
fix draggable button associate mouse cursor (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
XuYicong authored May 16, 2023
1 parent b07d385 commit 6ad9218
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions AKPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ class AKPlugin: NSObject, Plugin {
}

var cmdPressed: Bool = false

var cursorHideLevel = 0
func hideCursor() {
NSCursor.hide()
cursorHideLevel += 1
CGAssociateMouseAndMouseCursorPosition(0)
warpCursor()
}
Expand All @@ -54,7 +55,10 @@ class AKPlugin: NSObject, Plugin {

func unhideCursor() {
NSCursor.unhide()
CGAssociateMouseAndMouseCursorPosition(1)
cursorHideLevel -= 1
if cursorHideLevel <= 0 {
CGAssociateMouseAndMouseCursorPosition(1)
}
}

func terminateApplication() {
Expand Down

0 comments on commit 6ad9218

Please sign in to comment.