Re: NSButton sensing mouse over?
Re: NSButton sensing mouse over?
- Subject: Re: NSButton sensing mouse over?
- From: Darrin Filer <email@hidden>
- Date: Wed, 23 Jan 2002 11:05:49 -0500
I accomplished the same thing via a brute force technique but am still
looking for something more elegant. I ended up using tracking rects
since the behavior is more complicated than I anticipated. All three
buttons should display their hover images not only when the mouse is
hovering above them, but also when it is hovering between them. You can
actually drag the window from between the window widgets.
It took 400 lines of code to subclass NSView into something that behaves
exactly like the window widgets. However, this includes the ability to
draw the widgets over any type of background and still have their
'shadows' look right. Also, note intricacies like preventing window
ordering when using the widgets in a background window.
In regards to this line of code:
[cell setShowsBorderOnlyWhileMouseInside:YES];
How does this effect how its drawn? (Doesn't this just effect the
border?)
On Wednesday, January 23, 2002, at 12:11 AM, email@hidden wrote:
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.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.