Re: Button with a "mouseover" alternate image?
Re: Button with a "mouseover" alternate image?
- Subject: Re: Button with a "mouseover" alternate image?
- From: Robert Dell <email@hidden>
- Date: Mon, 16 Jan 2006 23:21:37 -0500
Theodore H. Smith wrote:
On 15 Jan 2006, at 21:53, Chad Weider wrote:
On Jan 15, 2006, at 2:49 PM, Theodore H. Smith wrote:
I'm trying to get an NSbutton, to have something like an
"alternateImage", except that it is a "mouseOverImage".
So this image will be displayed instead of the normal image, when
the mouse is over.
Any ideas how this is done?
You would probably want to use tracking rects. See the developer doc
"Handling Tracking-Rectangle and Cursor-Update Events in Views".
When the mouse rolls over a tracking rect you'll be sent a message to
mouseEntered: and then, when it leaves you'll get a message sent to
mouseExited:
Any idea how I'd draw the images and handle them? I know about
mouseOver events already.
i do that more or less on a daily basis with YASSE.
initButtonImages:
button1Image = [[NSImage alloc] initWithContentsOfFile: [self getImageLocation: @"button1"]];
[button1Image setScalesWhenResized: YES];
button1 = [[NSButton alloc] init];
initButtonPalette:
[button1 setButtonType: NSRadioButton];
[button1 setTitle: nil];
[button1 setTarget: self];
[button1 setTransparent: NO];
[button1 setImage: button1Image];
[button1 setAction: @selector(button1Press:)];
[button1 sizeToFit];
[button1 setFrame: NSMakeRect(0, 30, 30, 30)];
[button1view addSubview: button1];
[button1 setNeedsDisplay: YES];
[button1 display];
myProcessCommand:
if ([buttonnumber isEqualToString: @"1"])
{
[button1Image dealloc];
button1Image = [[NSImage alloc] initWithContentsOfFile: path];
if (buttonpalettevisible)
{
[buttonpalette close];
[self initButtonPalette];
}
}
the lines are from several locations. it may not be good but it works, that's the main thing.
robert
_______________________________________________
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