0

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 and others mouse button clicks?

1
  • I'm not sure what is the final task, but to define a new button type it's better to subclass the NSButtonCell. Commented Aug 5, 2011 at 9:12

2 Answers 2

1

NSControl derives, indirectly, from NSResponder, and that has methods mouseDown:, rightMouseDown: and otherMouseDown:, all three taking an NSEvent* as parameter.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. More exactly is the NSView class has method - (void)rightMouseDown:(NSEvent *)theEvent is all I need.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.