NSButton catch a mouse click event
I have the code
#import <Cocoa/Cocoa.h>
@interface MyButton : NSButton
{
}
- (void)mouseDown:(NSEvent *)theEvent;
@end
#import "ContextMenuButton.h"
@implementation MyButton
- (void)mouseDown:(NSEvent *)theEvent;
{
// ...
}
According to the NSControl Class Reference mouseDown
informs the receiver that the user has pressed the left mouse button.
How could I catch right a开发者_C百科nd others mouse button clicks?
NSControl
derives, indirectly, from NSResponder
, and that has methods mouseDown:
, rightMouseDown:
and otherMouseDown:
, all three taking an NSEvent*
as parameter.
NSButton
responds only on the left button click. Anyway take a look at NSEvent type. It determines a lot of info about event including wich button was pressed.
精彩评论