Re: NSButton sensing mouse over?
Re: NSButton sensing mouse over?
- Subject: Re: NSButton sensing mouse over?
- From: email@hidden
- Date: Tue, 22 Jan 2002 21:11:35 -0800
i just responded privately that this doesn't work, then figured it
out... when i tried moving my call to
setShowsBorderOnlyWhileMouseInside: till *after* i added the button to
the window... then it works... (it might be good to document that this
is the case someplace.)
thanks chuck.
here's the code for the curious:
NSButton *button = [[NSButton alloc] initWithFrame:NSMakeRect(4,
335, 68, 24)];
NSButtonCell *cell = [[TrafficLightCell alloc] init];
[button setButtonType:NSMomentaryChangeButton];
[button setCell:cell];
[[window contentView] addSubview:button];
// if this next line is moved above the addSubview line above, then
TrafficLightCell's mouseEnter/Exit methods aren't called.
[cell setShowsBorderOnlyWhileMouseInside:YES];
Now I have a button that implements the red/yellow/green buttons of
NSWindow for use in borderless windows! (like iPhoto)
(if only i could find the nice images Appearance uses, i wouldn't have
to use my imperfect screengrabbed versions...)
I'm assuming that apps like iPhoto and iTunes create their windows using
carbon and then use DrawThemeTitleBarWidget(...)
On Tuesday, January 22, 2002, at 07:55 PM, Chuck Pisula wrote:
You'd have to do it yourself by looking for mouseEntered, and
mouseExited messages, and then doing your own drawing.
-c
On Tuesday, January 22, 2002, at 07:29 PM, email@hidden wrote:
Is there a way to have a custom NSButtonCell subclass draw differently
if the mouse has entered/exited the button, without being pressed?
All I can find is isHighlighted... which tracks when the button is
pressed.