2

Mac os El Capitan introduced a feature called "Shake mouse pointer to locate" - it seems to ignore the cursor visibility set by CGDisplayHideCursor / CGDisplayShowCursor

I need to completely hide the mouse cursor for my cross platform first person game.

How can I get around this problem?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Tyron
  • 1,938
  • 11
  • 30
  • 2
    We also have run into this problem when capturing the cursor during a screenshot and have been unable to find a solution. It appears to remain burned in even when you have the cursor set to be hidden. The best solution we've found is to suggest to users that they disable this "feature" in System Preferences. – theeagle Nov 14 '18 at 17:38
  • 1
    Thanks, I'll do that until a better solution comes along – Tyron Nov 14 '18 at 17:41
  • 1
    @theeagle check out below solution \o/ – Tyron Nov 15 '18 at 19:11
  • Excellent, thanks! – theeagle Nov 15 '18 at 20:12

1 Answers1

3

No system event to handle this in my experience. It's not the prettiest, but you can follow the advice in this blogpost and rehide the cursors when listening to the mouseMove event.

override func mouseMoved(with event: NSEvent) {
    NSCursor.hide()
}
NickSpag
  • 581
  • 4
  • 11
  • 1
    Thank you very much, that did indeed solve the problem. I'm calling CGDisplayHideCursor instead though, that also seem to work. – Tyron Nov 15 '18 at 19:07