Re: [Newbie question] Subclassing NSButton
Re: [Newbie question] Subclassing NSButton
- Subject: Re: [Newbie question] Subclassing NSButton
- From: Tommy Nordgren <email@hidden>
- Date: Sun, 6 Aug 2006 21:24:47 +0200
On Aug 6, 2006, at 8:52 PM, JECKER Frédéric wrote:
Hi all,
I create a simple window with one button and one NSTextField
The idea is to display contextual text when the button is hovered
by the mouse.
To do this I subclassed the NSButton class and created the
HoverNSButton class (code attached) which uses the following code to
catch the mouse events :
- (void)viewDidMoveToWindow{
[self addTrackingRect:[self visibleRect] owner:self userData:nil
assumeInside:NO];
}
- (void) mouseEntered:(NSEvent *)theEvent{
NSLog(@"Mouse Entered");
}
- (void) mouseExited:(NSEvent *)theEvent{
NSLog(@"Mouse Exited");
}
This works well, but I tried to turn this a little more dynamic by
adding the following method to my HoverNSButton class:
- (void) setContext:(NSString*)content container:(NSTextField*)field{
NSLog(@"Setting Context");
NSLog(content);
text=content;
NSLog(text);
textfield=field;
}
The goal of this method is to be called by the window controller to
set the text for each HoverNSButton.
I call this method for each button in my controller but this don't
work.
I tried to debug the whole thing but the debugger doesn't enter the
setContext method.
Any ideas???
Thanks a lot
NSButton or it's base classes don't call the method
setContext:container:
because it is not an override of a standard method.
If you wan't it to be called, you must call it yourself from an
appropriate
method that your class overrides.
------------------------------------------------------
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden