One Quickie


Checking for modifier keys (NSView->General)

In your mouseDown:

    if ([event modifierFlags] & NSShiftKeyMask) {
        constrain = YES;
    } 
If you need to check them outside of your mouseDown, and if you're on 10.6 or beyond, you can use +[NSEvent modifierFlags];

If you're stuck in 10.5 or older, you need to do something like this: dip into carbon:

Carbon and AppKit use different constants for the modifiers, however, so you may need to convert between them depending on your situation. (Thanks to Peter Hosey for the Carbon trick)

(Thanks to Mike Ash for pointing out the new 10.6 API)



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com