April 2015
Intermediate to advanced
556 pages
17h 47m
English
An event object has all the information about what the user did to trigger the event. When you are dealing with mouse events, you might be interested in the following properties:
var locationInWindow: NSPoint { get }
Returns the location of the mouse event.
var modifierFlags: NSEventModifierFlags { get }
Tells you which modifier keys the user is holding down on the keyboard. This enables the programmer to tell a Control-click from a Shift-click, for example. The code would look like this:
override func mouseDown(theEvent: NSEvent) { let flags = theEvent.modifierFlags if flags & .ControlKeyMask == .ControlKeyMask { // handle Control-click } if flags & .ShiftKeyMask == .ShiftKeyMask { // handle Shift-click } } ...Read now
Unlock full access