Q:

Cocoa/Objective-C NSButton event handling?

I'm wondering how to handle an event on NSButton click, I've searched all over the internet and found lots of things like RightMouse button event handling, event handling on mouseup, event handling in c++, etc. but nothing that's just normal event handling, seems like everyone knows it already so I can't find any information about it? And I'm doing it all without .nib files or any kind of builder, it's pure text, so how do I handle button click event, I already have window and button created?

A:

Did you try this ?
NSButton *myButton = [[NSButton alloc] initWithFrame:myFrame];
[myButton setTarget:self];
[myButton setAction:@selector(myMethodToCallOnClick:)];

