FROM : Gary L. Wade
DATE : Fri May 30 20:43:26 2008
As for the color choices to use when drawing selected color text, what
I've found most readable to my users is to continue using the selection
color as chosen by the user but to draw the text shadowed as the Finder
does it, with the text being white and the shadow color being the color
of the text.
So, red text being selected with a blue highlight color would show up as
white text, red shadow, drawn on top of a blue field...kind of American
patriotic, don't you think? ;-)
I've also darkened or lightened the shadow color if it's too close to
the highlight color, causing a near-invisible blending; if the highlight
color is light, I darken it, but I lighten it if the highlight color is
a dark color. Using HSB/HSL helps with this adjustment. This usually
works because the colors in my application are used to denote particular
states of information and so are typically very different. And, if you
want to help out color-blind users (I'd consider the worst case of color
blindness), you could use a grayscale check for the near-invisible
blending issue.
There's no perfect solution to this, but I hope this helps you consider
your options.
Mattias Arrelid wrote:
> Hi everyone,
>
> We have a subclass of NSTextView (SPTextView). A couple of these have
> some text with [NSColor grayColor] set as the
> NSForegroundColorAttributeName. It looks good, but when the user
> starts selecting text things go badâ„¢. Since grey on light blue (the
> default system selection color) isn't very readable one could argue
> that we should change the selection color. That is pretty straight
> forward, but we'd rather not mess with this since the user might have
> her own highlight color set (through System Preferences / Appearance).
>
> The next approach would be to use NSTextView's
> setMarkedTextAttributes:. It takes a dictionary as paramater, with the
> following restrictions (according to the documentation): "A dictionary
> of attributes used to draw marked text. Text color, background color,
> and underline are the only supported attributes for marked text.".
> Regardless of how I try to specify these (I assume the attributes that
> are valid are NSForegroundColorAttributeName,
> NSBackgroundColorAttributeName, NSUnderlineColorAttributeName and
> NSUnderlineStyleAttributeName), that call doesn't affect the view.
>
> As a last resort, we could implement
> setSelectedRange:affinity:stillSelecting: in our NSTextView subclass,
> and set the foreground color of the selected range... but that would
> mean that we would have to change it back to whatever color it had
> before the selection took place. That doesn't feel right.
>
> Reading http://developer.apple.com/documentation/Cocoa/Conceptual/TextEditing/Tasks/SetFocus.html
> indicates that setMarkedTextAttributes: should do just this, but I
> cannot seem to get it working.
>
> Any suggestions?
>
> Best regards
> Mattias
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
DATE : Fri May 30 20:43:26 2008
As for the color choices to use when drawing selected color text, what
I've found most readable to my users is to continue using the selection
color as chosen by the user but to draw the text shadowed as the Finder
does it, with the text being white and the shadow color being the color
of the text.
So, red text being selected with a blue highlight color would show up as
white text, red shadow, drawn on top of a blue field...kind of American
patriotic, don't you think? ;-)
I've also darkened or lightened the shadow color if it's too close to
the highlight color, causing a near-invisible blending; if the highlight
color is light, I darken it, but I lighten it if the highlight color is
a dark color. Using HSB/HSL helps with this adjustment. This usually
works because the colors in my application are used to denote particular
states of information and so are typically very different. And, if you
want to help out color-blind users (I'd consider the worst case of color
blindness), you could use a grayscale check for the near-invisible
blending issue.
There's no perfect solution to this, but I hope this helps you consider
your options.
Mattias Arrelid wrote:
> Hi everyone,
>
> We have a subclass of NSTextView (SPTextView). A couple of these have
> some text with [NSColor grayColor] set as the
> NSForegroundColorAttributeName. It looks good, but when the user
> starts selecting text things go badâ„¢. Since grey on light blue (the
> default system selection color) isn't very readable one could argue
> that we should change the selection color. That is pretty straight
> forward, but we'd rather not mess with this since the user might have
> her own highlight color set (through System Preferences / Appearance).
>
> The next approach would be to use NSTextView's
> setMarkedTextAttributes:. It takes a dictionary as paramater, with the
> following restrictions (according to the documentation): "A dictionary
> of attributes used to draw marked text. Text color, background color,
> and underline are the only supported attributes for marked text.".
> Regardless of how I try to specify these (I assume the attributes that
> are valid are NSForegroundColorAttributeName,
> NSBackgroundColorAttributeName, NSUnderlineColorAttributeName and
> NSUnderlineStyleAttributeName), that call doesn't affect the view.
>
> As a last resort, we could implement
> setSelectedRange:affinity:stillSelecting: in our NSTextView subclass,
> and set the foreground color of the selected range... but that would
> mean that we would have to change it back to whatever color it had
> before the selection took place. That doesn't feel right.
>
> Reading http://developer.apple.com/documentation/Cocoa/Conceptual/TextEditing/Tasks/SetFocus.html
> indicates that setMarkedTextAttributes: should do just this, but I
> cannot seem to get it working.
>
> Any suggestions?
>
> Best regards
> Mattias
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Mattias Arrelid | May 30, 13:25 | |
| Ross Carter | May 30, 17:15 | |
| Gary L. Wade | May 30, 20:43 | |
| Mattias Arrelid | Jun 11, 12:24 | |
| Douglas Davidson | Jun 11, 17:30 | |
| Mattias Arrelid | Jun 11, 18:15 | |
| Mattias Arrelid | Jun 12, 11:14 | |
| Mattias Arrelid | Jun 12, 11:47 | |
| Graham Cox | Jun 12, 15:46 | |
| Douglas Davidson | Jun 12, 17:40 | |
| Mattias Arrelid | Jun 12, 18:19 |






Cocoa mail archive

