NSButton Up/Down Events
Jonathan Toolan
jtoolan at star.net.uk
Fri Feb 9 09:05:00 PST 2007
Brad,
I think what you're looking for is "type":
From
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/
Classes/NSEvent_Class/Reference/Reference.html#//apple_ref/occ/instm/NSE
vent/type
NSEventType which = [event type];
Returns the type of the receiving event.
- (NSEventType)type
The type will be one of the following:
NSLeftMouseDown
NSLeftMouseUp
NSRightMouseDown
NSRightMouseUp
... Etc ...
But I could be wrong. :)
Hope that helped.
Jonathan
-----Original Message-----
From: macosx-dev-bounces at omnigroup.com
[mailto:macosx-dev-bounces at omnigroup.com] On Behalf Of Brad Carter
Sent: 09 February 2007 15:34
To: macosx-dev at omnigroup.com
Subject: NSButton Up/Down Events
I'm new to the list and very new to Cocoa and programming in general.
My only programming experience was Basic about 20 years ago when my
father put me in classes. I have just finished one book on Object C and
the other, Cocoa Programming for Mac OS X.
I have an AppleScript Studio app that I'm rewriting in Cocoa. The app
sends a curl command with a URL to a box that does relay closures and
that in turn controls the pan/tilt of a video camera. I have the
AppleScript set up using mouse down/up events so when the button is
pressed and held down the camera pans, when the button is release the
panning stops.
I can't figure out how to do this in Cocoa. I have subclassed NSButton
and overridden mouseDown: and mouseUp and display this to NSLog
confirming my success. How do I tell what button was pressed in the
mouseDown: method? I can't find anything in NSEvent that would hint
that this info would be passed as an NSEvent. Here's my code below.
Thanks,
Brad
- (void)mouseDown:(NSEvent *)event
{
NSLog(@"down");
[super mouseDown:event];
[self mouseUp:event];
}
- (void)mouseUp:(NSEvent *)event
{
NSLog(@"up");
}
--------------------------------------------------------------
The smime.p7s file below is my public encryption key, not a virus.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
Disclaimer
This message and its attachments is intended for the above named only, and may be privileged or confidential. If it has come to you in error you must take no action based on it, nor must you copy or show it to anyone. If you have received this message in error please destroy it and contact the sender, either via our switchboard on +44 (0) 1285 884420 or via return e-mail. All reasonable precautions have been taken to ensure that no viruses are present in this e-mail, however, Star Technology Services Ltd cannot accept responsibility for loss or damage arising from the use of this message or attachments and recommend that you undertake your virus checking procedures prior to use. Star Technology Services Ltd does not enter into any form of contract via this medium, nor is our staff authorised to do so on our behalf. Any opinions expressed in this e-mail are those of the sender, and will not reflect the opinions of Star Technology Services Ltd unless specifically stated.
Star Technology Services Ltd, 1240 Lansdowne Court, Gloucester Business Park, Gloucester, Gloucestershire, GL3 4AB, United Kingdom. A company registered in England No: 3077786 http://www.star.net.uk/
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
More information about the MacOSX-dev
mailing list