NSButton Up/Down Events

Brad Carter bcarter at mac.com
Fri Feb 9 07:34:15 PST 2007


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.




More information about the MacOSX-dev mailing list