I think I finally have a working solution in my notes app 🚀
Don't want to declare victory too early. Will need to do some more testing, but my solution seems really promising.
I am now able to hover the ellipsis button in a collapsed heading and the `NSCursor` will correctly change to the `.pointingHand`.
Before it would immediately change back to the default, which is the `.iBeam` for text views. This is because the ellipsis button is positioned on top of an `NSTextView`, and text views in AppKit are very aggressive in controlling the `NSCursor` type. Even if you set `.onHover` to change cursor in SwiftUI, it will just get overridden by the text view...
My solution involved controlling the cursor on AppKit-level, as I needed more control than what SwiftUI offers.
Part of my solution involved overriding the function `cursorUpdate()` so that can control exactly when the cursor should update. I have a guard that returns early to avoid changing cursor if the hit view is the ellipsis button.
I also override the function `mouseMoved()` to constantly set `NSCursor.pointingHand()` whenever the mouse is moved over the button.
On a rare occasion, the cursor will flicker, but from my testing, this happens very rarely. #dev #AppKit #SwiftUI #macOS
View quoted note →
My solution involved controlling the cursor on AppKit-level, as I needed more control than what SwiftUI offers.
Part of my solution involved overriding the function `cursorUpdate()` so that can control exactly when the cursor should update. I have a guard that returns early to avoid changing cursor if the hit view is the ellipsis button.
I also override the function `mouseMoved()` to constantly set `NSCursor.pointingHand()` whenever the mouse is moved over the button.
On a rare occasion, the cursor will flicker, but from my testing, this happens very rarely. #dev #AppKit #SwiftUI #macOS
View quoted note →
