O'Reilly logo

Mac Application Development by Example Beginner's Guide by Robert Wiebe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – detaching the mouse cursor from the mouse hardware

The solution to this problem is to detach the mouse cursor from the mouse hardware (typically called capturing the mouse) whenever a touch event is active so that the cursor is not moved by touch events. In addition, since a "stuck" mouse cursor may be cause for concern to our App user, we can hide the mouse cursor when touches are active.

  1. In Xcode, click on the file named BTSFingerView.h in the project navigator and add the following flag to the interface:
    @interface BTSFingerView : NSView
    {
    
    // Define a flag so that touch methods can behave
        // differently depending on the visibility of
        // the mouse cursor
        BOOL m_cursorIsHidden;
    
    }
  2. In Xcode, click on the file named BTSFingerView.m ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required