• 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
Changing the IBeamCursor colour in an NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: NSevent handling in panther
  • Next by Date: Re: Cocoa autoscroll question
  • Previous by thread: loading apps above other windows?
  • Next by thread: RE: Changing the IBeamCursor colour in an NSTextView
  • Index(es):
    • Date
    • Thread