Track mouse movement Mac

person shubham sharmafolder_openMAC Os, Swiftlocal_offer, access_time April 8, 2019

 

What going on here is.

  1. Simple toggle action to flip between playing/not-playing state and reflect that in the color state.
  2. Adds a NSTrackingArea to the view. The owner is this view controller so it will receive the mouseMoved: event. The option .mouseMoved is required to set this up.
  3. Removes the tracking area from the view when the slide show isn’t playing and sets setHiddenUntilMouseMoves to false.
  4. The mouseMoved: handler
  5. The setHiddenUntilMouseMoves is set true after two seconds as long as the tracking area exists and its not already waiting. Note the weak reference to self prevents a possible retain cycle here.

This isn’t perfect as you might find that the cursor hides once after leaving your window but should get you going in the right direction.

warningComments are closed.