I have a totally custom NSControl
with its totally custom NSCell
.
Now I want to implement some Mouse interaction. For example when user clicks over the control
I want to change the control state to highlight
so the questions are:
1) Where I have to deal with the mouse event? In the NSControl
or directly in the NSCell
?
At the moment I'm working with this code in the NSCell subclass:
-(BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView{
[self setHighlighted:YES];
return YES;
}
-(void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag{
[self setHighlighted:NO];
}
2) Is the NSCell
state automatically managed by the NSControl
? If I set the NSControl
stete to highlight
it will be mirrored to the NSCell
?
3) and what about the enabled attributes? At the moment I wrote this code in the NSControl: And this code in the NSControl
-(void)setEnabled:(BOOL)flag{
[super setEnabled:flag];
[[self cell]setEnabled:flag];
[self updateCell:[self cell]];
}
Have you particular suggestion to work with mouse event with a custom NSControl+NSCell?