Re: Highlighting chars in an NSTextField?
Re: Highlighting chars in an NSTextField?
- Subject: Re: Highlighting chars in an NSTextField?
- From: Clark Williams <email@hidden>
- Date: Thu, 26 Jan 2012 14:51:11 -0800
First a thank you to Fritz, Jens and Ken!
I very much appreciate your assistance and comments.
There is some confusion about what I meant by "highlighting", understandable since I didn't really described what I was trying to do, so here goes:
My definition of "Highlighting":
Given any text presentation in any text container --- then (for me):
"Drawing" is the display of the glyphs in a font family.
"Selection" is an interactive designation by the user or the program to indicate it is about to perform an action on the selected glyphs.
"Highlighting" is simply the drawing of the glyphs in a way (usually by changing the background of the glyphs) so that the glyphs are distinct from other glyphs already drawn.
However this drawing may not altering the font family nor the base line (same size and shape).
The highlighting of glyphs does not indicate an intent to interact with them in any way.
Selection may include all, part, or none of a highlight.
Highlight is not an included attribute of the selection once the action has been applied to the selection.
Perhaps Fritz's 5th point is the way to go although it seems to me that a message such as:
[someNSTextField setTextHighlighted: (BOOL)highlightOnOrOff: (NSColor)color: (NSInteger)startPosition: (NSInteger)endPosition];
or perhaps:
[someNSTextField setTextHighlighted: (BOOL)highlightOnOrOff: (NSColor)color: (NSRange) range];
would be useful.
I have used attributed strings in the past (especially to do HTML and RTF) but it seems to me that attributed strings also saw the receivers as entire entities so I don't see how I might change the background of just a small selection of text. I guess I need to re-read attributed text class again.
Thank you all again.
Any other suggestions are still appreciated.
Clark
On Jan 26, 2012, at 14:19, Jens Alfke wrote:
>
> On Jan 26, 2012, at 11:31 AM, Clark Williams wrote:
>
>> Is this the wrong approach?
>
> Yeah. Cell highlighting is for buttons and button-like controls to change visual state when pressed. It has no effect on text cells and it's definitely not for selecting text.
>
> What I would do is create an NSAttributedString that has a custom background color for the character range you want highlighted, then set that as the text field's attributedStringValue.
>
> —Jens
>
>
_______________________________________________
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