Re: Custom mouse cursor in NSTextView
Re: Custom mouse cursor in NSTextView
- Subject: Re: Custom mouse cursor in NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Mon, 23 Jun 2008 12:45:57 -0700
On Jun 13, 2008, at 8:58 AM, Todd Ransom wrote:
I have a fullscreen text view in my app that allows the user to set
a foreground and background color. Problem is, for some
configurations the default I-beam mouse cursor does not show up very
well so I want to provide a custom I-beam cursor in the same color
as the text.
I put together a bezier path to draw the I-beam and overrode
resetCursorRects like this:
- (void)resetCursorRects
{
[self addCursorRect: [self visibleRect] cursor: [self
bigIBeamCursor]];
}
This works great as long as I use it in an NSView subclass. But as
soon as I change my class to inherit from NSTextView it stops
working. resetCursorRects is still called, but the text view is
doing some kind of magic to change the cursor itself. I have also
tried overriding - (void)addCursorRect:(NSRect)aRect cursor:
(NSCursor *)aCursor to replace the generic ibeam with my own, but
that only seems to get called if I override resetCursorRects and it
does not affect the cursor appearance in the text view either.
Has anyone else out there successfully changed the mouse cursor on a
text view? What did you need to do?
NSTextView sets the cursor over itself dynamically, based on
considerations including the text under the cursor. It does so in -
mouseEntered:, -mouseMoved:, and -cursorUpdate:, so those would be
points to consider overriding.
Douglas Davidson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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