RE: Changing the IBeamCursor colour in an NSTextView
RE: Changing the IBeamCursor colour in an NSTextView
- Subject: RE: Changing the IBeamCursor colour in an NSTextView
- From: Keith Blount <email@hidden>
- Date: Mon, 28 Feb 2005 02:45:50 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Hmm, still no joy on this... All I want to do is
change the colour of the I-beam cursor in an
NSTextView for a full screen mode, but it is proving
incredibly difficult.
In addition to the code in my original message, I
tried adding a tracking rect to my text view
subclass's resetCursorRects in addition to
addCursorRect:..., and called [iBeamColorCursor set]
in mouseEntered: - this improved things (though I
don't see why I should have to do this when I've
already set setOnMouseEntered for my cursor), but the
results are still incredibly erratic. I will have a
coloured I-beam cursor for the most part, and then
suddenly it will return - apparently randomly - to a
being a black cursor. I've used NSLog() in
mouseExited: to see if at these points the cursor has
left my tracking rect (ie. to check if it is just a
problem with my tracking rects being messed up), but
it hasn't - my tracking rects seem fine.
The trouble is that the I-beam cursor seems to be set
by something other in the text system than
NSTextView's resetCursorRects. If anybody knows an
easy way of changing the cursor for a text view, I
would be really grateful.
Many thanks again,
Keith
--- Original message ---
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!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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