Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to do modifier keys?

How to do modifier keys?
Thread Tools
Mac Elite
Join Date: Oct 2000
Location: Edinburgh, Scotland
Status: Offline
Reply With Quote
Aug 31, 2001, 08:11 PM
 
Hi, old timers will know I've not posted in ages, but I hope I'm still good for some advice!

Anyway, I've been doing a lot of programming, mostly in Cocoa-java, but I've come across a problem. I've got a button that I want to do three different things depending on whether control, option or nothing is held down while the button is clicked. I've got the button attached to a method/action and naturally, it does the correct thing when I just press it.

How do I find out which key was held down at the same time as the button was pressed?

TIA for your help.
ClamXav - the free virus scanner for Mac OS X | Geobunny learns to fly
     
Forum Regular
Join Date: Jan 2000
Location: California
Status: Offline
Reply With Quote
Aug 31, 2001, 10:43 PM
 
I only know how to do it in ObjectiveC. Figuring out the java calls shouldn't be hard.

You want to look in NSEvent and NSApplication.

if ([[NSApp currentEvent] modifiers] == NSControlKeyMask) {
[do something];
}

NSApp is just a shortcut for [NSApplication sharedApplication]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:53 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2