Changing the IBeamCursor colour in an NSTextView
Changing the IBeamCursor colour in an NSTextView
- Subject: Changing the IBeamCursor colour in an NSTextView
- From: Keith Blount <email@hidden>
- Date: Sun, 27 Feb 2005 11:00:31 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Hello,
I am working on a fullscreen text editing mode for my
app and, because the user can customise the background
colour of the text view so that it is black (for
instance) in full screen, I would like to be able to
change the colour of the I-beam cursor within the text
view. ie. If the text view is black, the I-beam cursor
will be almost invisible unless its colour is changed.
I thought this would be relatively straightforward,
but I can't get it to work. I started by subclassing
NSTextView and overriding -resetCursorRects as
follows, in an effort (as a test) to replace the
default I-beam cursor with a blue one:
- (void)resetCursorRects
{
NSCursor *iBeam = [NSCursor IBeamCursor];
NSImage *iBeamImg = [iBeam image];
NSRect imgRect = {NSZeroPoint, [iBeamImg size]};
[iBeamImg lockFocus];
[[NSColor blueColor] set];
NSRectFillUsingOperation(imgRect,NSCompositeSourceAtop);
[iBeamImg unlockFocus];
NSCursor *iBeamColor = [[NSCursor alloc]
initWithImage:iBeamImg hotSpot:[iBeam hotSpot]];
[self addCursorRect:[self visibleRect]
cursor:iBeamColor];
[iBeamColor setOnMouseEntered:YES];
[iBeamColor release]; // I have tried not releasing
here, with no effect
}
However, this does not work as expected. The blue
I-beam cursor sometimes appears - if moving very
slowly into the view from the top or bottom, for
instance - but it always reverts to the black default
I-beam cursor.
Because this didn't work, I tried overriding
addCursorRect:cursor: so that it always changed the
passed-in cursor to blue, but this had no effect.
It seems that NSTextView is doing something other than
just calling resetCursorRects to set the I-beam
cursor, but I can't find anything in the docs about
this. Does anyone know how I can successfully change
the colour of the I-beam cursor in an NSTextView?
Many thanks in advance for any help,
Keith
__________________________________
Do you Yahoo!?
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250
_______________________________________________
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