Highlighting chars in an NSTextField?
Highlighting chars in an NSTextField?
- Subject: Highlighting chars in an NSTextField?
- From: Clark Williams <email@hidden>
- Date: Thu, 26 Jan 2012 11:31:42 -0800
I have a NSTextField with a string displayed. I want to hightlight the 1st 2 chars then the next 2, then the next 2, etc. I tried the following code: but does not seem to work. At least it doesn't highlight anything.[currentDataTextBox setStringValue:@"AaBbCcDdEeFfGgHh"];
NSCell* currentCell = [currentDataTextBox cell];
NSView *currentView4Cell = [currentCell controlView];
NSRect currentRect = [currentDataTextBox bounds];
// guess at the points/character
double pointsPerChar = currentRect.size.width / [[currentDataTextBox stringValue] length];
NSLog ( @"pt/char: %f", pointsPerChar );
currentRect.origin.x += 0.0; // bump this to change the origin in loop
currentRect.size.width = pointsPerChar * 2.0;
[currentCell highlight:YES withFrame:currentRect inView:currentView4Cell];
Is this the wrong approach? Pointers to code samples, suggestions, etcetera, would be appreciated. TIA Clark Williams
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden