• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Button with a "mouseover" alternate image?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Button with a "mouseover" alternate image?


  • Subject: Re: Button with a "mouseover" alternate image?
  • From: "Theodore H. Smith" <email@hidden>
  • Date: Mon, 16 Jan 2006 13:02:46 +0000


Apologies for sending the previous email off-list, I'm used to simply pressing the "reply" button in MacOSX Mail, which unfortunately defaults to off-list replies!


On 16 Jan 2006, at 00:13, Chad Weider wrote:


On Jan 15, 2006, at 5:52 PM, 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.

Not quite sure what you mean.

There is a method imageRectForBounds: in NSCell, that should give you where the button is drawing the images.

There is also drawImage:withFrame:inView: that might do what you need.

What I'm trying to get at, is this:

Is there a better way, or simpler way, or preferred way for creating a mouseOverImage behaviour, over the way that I suggested.

Just a reminder, my original suggestion is this:

self->MySubClassesSpecialState = kMouseOver;
[super mouseOver];
[self display];


In display, I'd do this:

if (MySubClassesSpecialState == kMouseOver) {
	[self setImage : SomeImage];
	[super display];
	[self setImage : OldImage];
}


Is there a simpler, or better or more preffered way to do some kind of mouseOverImage behaviour than this very hacky and bad way I just suggested, which involves adding an extra property to the class? When I see myself having to add extra state properties to a class just to know what to draw when, I start wondering if I am doing something wrong. I can understand having to add an extra image property, but an extra state property... that just seems like I'm doing this the most obvious and less easy way.



Thanks for those tips for how to get access to standard focus ring drawing routines!


_______________________________________________
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


  • Follow-Ups:
    • Re: Button with a "mouseover" alternate image?
      • From: Andy Armstrong <email@hidden>
References: 
 >Button with a "mouseover" alternate image? (From: "Theodore H. Smith" <email@hidden>)
 >Re: Button with a "mouseover" alternate image? (From: Chad Weider <email@hidden>)

  • Prev by Date: Re: Button with a "mouseover" alternate image?
  • Next by Date: Re: Button with a "mouseover" alternate image?
  • Previous by thread: Re: Button with a "mouseover" alternate image?
  • Next by thread: Re: Button with a "mouseover" alternate image?
  • Index(es):
    • Date
    • Thread