Re: question about custom cursor
Re: question about custom cursor
- Subject: Re: question about custom cursor
- From: Fred Hope <email@hidden>
- Date: Wed, 7 Mar 2007 13:04:27 -0800
Brilliant. It works perfectly now. As you can see, I'm still
learning my way around some aspects of Cocoa and having to figure
stuff out on my own (or with help). Oh, and my cursor is titled
something more descriptive than "cursor.tiff"; I just called it that
in my posts for simplicity...and maybe the app I'm working on is a
secret ;). Anyway thanks loads for the help.
-Fred
On Mar 7, 2007, at 3:59 AM, Alastair Houghton wrote:
<snip>
Also, you don't say where you're doing all of this; you should be
doing it in the -resetCursorRects method of your view (if
necessary, you will need to subclass whatever you're using for
imgView), so the full solution should look like this:
<snip>
You might consider having the cursor variable as an instance
variable of your class, or even a global (but probably static)
variable in the file containing the class's code. In the former
case you'd initialise it from -initWithFrame:, and in the latter,
probably from +initialize. Using a static variable with local scope
like the one in the example above is quite a neat trick, though, as
it makes it easy to lazily create things without adding unnecessary
global variables.
BTW, the reason for using -visibleRect rather than -bounds is that
if you put your view inside an NSScrollView (or, in fact, inside an
NSClipView, which is where it will be if you put it in a scroll
view with Interface Builder), not all of the view will necessarily
be visible in your window. If you were to stray outside the visible
area, you might see unusual behaviour in the area outside the
content region of the scroll view because of the way cursor and
tracking rectangles are implemented.
I'd also recommend using a more descriptive name than "cursor.tiff"
for the image file itself; in a year's time, when you come back to
your code, you'll likely have to open the tiff file up to see what
sort of cursor it's for if you use names like that :-)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden