I had some time to play around with #AppKit to figure out a fix to the problem. #dev #macOS #SwiftUI
**Recap of the problem:** When I have an overlay above an `NSTextView`, I don't want the iBeam cursor to show when hovering the overlay. But it will actually change to iBeam because the `NSTextView` is below and it just has higher priority, so it will override the cursor. This does not have a straightforward fix, so I had to figure it out on my own...
It was not as simple as I thought. I did end up using both `resetCursorRects()` and `addCursorRect()` as I anticipated, but that alone was not enough...
I also had to override `mouseEntered()` in the `NSTextView` to block it from changing `NSCursor` to iBeam whenever `hitView` is true. It would flicker to iBeam when hitting the edge of a text view. By overriding `mouseEntered()` in the text view, I could explicitly tell it NOT to do it by blocking the `NSEvent`.
I did the same for `mouseMoved()` and `mouseExited()`.
The `hitView` is whatever SwiftUI element I have assigned with `.background(ArrowCursorView())`.
After testing, this seems to work perfectly, except for ONE thing 😩
It will not allow showing the iBeam in the search field I have inside the overlay (it also gets overridden), so that will be the next task to solve 😁
📝 3ccb5c76…