Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX - How to tell if cursor is visible

I understand that this question has already been answered:

Detect if cursor is hidden on Mac OS X

But at this point, the function "CGCursorIsVisible" has been deprecated. According to the help literature, there is no replacement.

https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/c/func/CGCursorIsVisible

When using the hide and show functions (CGDisplayHideCursor / CGDisplayShowCursor), no reference to the cursor's visibility is returned. Although a show / hide counter is maintained by quartz, there's no way of accessing that value.

So, how do we find out if the cursor is visible or not?

like image 206
AudioGL Avatar asked Mar 25 '14 21:03

AudioGL


People also ask

How do I know if my cursor disappears Mac?

If your mouse cursor isn't showing up, a simple click-and-drag operation may bring it up. Simply hold as though you are selecting an item or bunch of text, then release. This should bring up your mouse cursor on the screen!

How do I see cursor on Mac?

On your Mac, choose Apple menu > System Preferences, then click Accessibility . Click Display, then click Pointer.

Why is my cursor invisible?

Check the Cable or Batteries. For a wired mouse, check the cable and ensure that it doesn't have any signs of damage. If you're using a wireless mouse, then you need to take a different approach. If the mouse pointer disappears, try using new batteries and see if this resolves the issue.


1 Answers

I ran into the very same problem and could not find a valid answer to this problem.

I solved it by implementing a counter which is set to 0 when my application starts. I increase it everytime I hide the cursor and then I can unhide while the _counter != 0.

Your Mac seems to have an own counter for each application... So if your application is not in foreground and it uses the [NSCursor hide] command, it will still be visible but become invisible, when your app becomes keyWindow again.

like image 187
Git.Coach Avatar answered Sep 20 '22 08:09

Git.Coach