 |
 |
Keys.
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
Cocoa question(s):
I have a button. How can I make it so when I press a key, that button is activated?
How can I capture key events in general?
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
Get info on it in interface builder and there is a field wich say something like key. Below it is also a popup menu with stuuf like retun and tab in it so you don't have to remember that tab is \t. Just put the key in the key field in Interface Editor.
Capturing keyboard events, for a game or something is kind of hard. I never really looked into how to do that . If all that you want to do is make buttons respond to keystrokes then just use Interface Builder.
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
I tried that key thing a while ago, but I couldn't get it to work. Is there any place which has code for a game in Cocoa, or something that gets into more detail with the event loop than the standard runtime?
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status:
Offline
|
|
I have never actually done this but I will be trying soon and if I have any luck I will post the example and send you a link but I am pretty sure that you can create an object of type NSEvent and use that to find out what is going on. It has a "keyDownEvent" or something that tells you when someone is pressing a key and you can then use that same object, I think, to get the code of the key that was pressed. Just search the apple documentation for "NSEvent" and you should get something. I seem to recall them having some decent documentation for this Class.
Hope that helps,
Jeff.
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
Someone answered this in another thread.
Basically, you can subclass NSWindow or NSApplication and have it capture events by overriding keyDown  NSEvent *)aEvent
Overriding event handling in NSApplication is pretty powerful.
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|