user1716631
user1716631

Reputation: 11

Can not handle any event in a NSButton subclass

I have my subclass of NSButton which is added as a subview to a NSView subclass:

[parentView addSubview:button];

All my click events are passed to the super view object.

I tried any example google found and yet I can not handle no event. I mean I tried these:

In Button's init method:

[self setTarget:self];

[self setAction:@selector(clicked)]; 

also

[self setTarget:self];

[self setAction:@selector(methodWithNSEventParam:)]; 

also have them commented.

Never got to "clicked".

Overriding of the following methods (none of them ever called).

(void) mouseEntered:(NSEvent*)theEvent

(void) mouseExited:(NSEvent*)theEvent

(BOOL) mouseDownCanMoveWindow

(void) mouseDown:(NSEvent *)theEvent

(void) mouseUp:(NSEvent *)theEvent

(NSView*) hitTest:(NSPoint)aPoint

Upvotes: 1

Views: 310

Answers (1)

tng
tng

Reputation: 4346

I assume you are not using Interface Builder.

Make sure you are setting the target, action, and event correctly. Here's an example for pageControl.

[pageControl addTarget:self
                action:@selector(pageTurning:)
      forControlEvents:UIControlEventValueChanged];

Upvotes: 0

Related Questions