Reputation: 180
In OS X, the mouse cursor typically disappears when you are typing in a text field, in every app. Even when I am typing in this text field here on Stack Overflow, the cursor disappears. This makes sense most of the time. But in my app I want it to stay visible, because the user has to do a lot of clicking between text fields, and it is really nasty when the mouse is always gone.
How can I make the cursor stay visible when typing in an NSTextField
?
Upvotes: 3
Views: 1148
Reputation: 180
Ok, I solved it.
When you add a breakpoint at +[NSCursor setHiddenUntilMouseMoves:]
you will notice, that it is called by [NSTextField keyDown:]
Apple says it is no good idea to override this method in order to prevent the mouse from disappearing. So I used NSTextFieldDelegate to get notified on -(void)controlTextDidChange:(NSNotification *)obj
and -(void)controlTextDidEndEditing:(NSNotification *)obj
. Then I called [NSCursor setHiddenUntilMouseMoves:NO]
It is not 100% clean but it works.
Big thanks to Richard and Kurt for their great help :)
Upvotes: 3
Reputation: 154
It would be my guess that it is deep in apples code for the mouse to disappear when typing. Because even when you just start typing the mouse disappears, outside of a textbox even. Like when you click inside a browser window and type.
Upvotes: 2