FROM : Ricky Sharp
DATE : Mon Dec 31 15:18:03 2007
On Dec 31, 2007, at 7:55 AM, Shripada Hebbar wrote:
>>
>> this doesn't work:
>>
>> [myTextField setTextColor:[[NSColor redColor]
>> colorWithAlphaComponent:0.5]];
>> (result is plain red, ignoring alpha)
>>
> Documentation of 'colorWithAlphaComponent' says:
> "A subclass with explicit opacity components should override this
> method to return a color with the specified alpha."
> Thus the above code wont return you the expected color.
Actually, colorWithAlphaComponent: will indeed return the expected
color. I've use that API on many occasions and just created a test
app with two NSTextField instances. They use alpha of 0.5 and 0.25
respectively. The text was rendered correctly even when the text was
being edited (i.e. the field editor also did the right thing).
I ran my test on 10.5.1
I believe the problem may be within the cells/views hierarchy. If
things are marked as being opaque, alpha can be ignored. Is a custom
subclass of NSTextField being used?
___________________________________________________________
Ricky A. Sharp mailto:<email_removed>
Instant Interactive(tm) http://www.instantinteractive.com
DATE : Mon Dec 31 15:18:03 2007
On Dec 31, 2007, at 7:55 AM, Shripada Hebbar wrote:
>>
>> this doesn't work:
>>
>> [myTextField setTextColor:[[NSColor redColor]
>> colorWithAlphaComponent:0.5]];
>> (result is plain red, ignoring alpha)
>>
> Documentation of 'colorWithAlphaComponent' says:
> "A subclass with explicit opacity components should override this
> method to return a color with the specified alpha."
> Thus the above code wont return you the expected color.
Actually, colorWithAlphaComponent: will indeed return the expected
color. I've use that API on many occasions and just created a test
app with two NSTextField instances. They use alpha of 0.5 and 0.25
respectively. The text was rendered correctly even when the text was
being edited (i.e. the field editor also did the right thing).
I ran my test on 10.5.1
I believe the problem may be within the cells/views hierarchy. If
things are marked as being opaque, alpha can be ignored. Is a custom
subclass of NSTextField being used?
___________________________________________________________
Ricky A. Sharp mailto:<email_removed>
Instant Interactive(tm) http://www.instantinteractive.com
| Related mails | Author | Date |
|---|---|---|
| charlie | Dec 31, 06:50 | |
| Shripada Hebbar | Dec 31, 14:55 | |
| Ricky Sharp | Dec 31, 15:18 | |
| charlie | Dec 31, 15:20 | |
| Ricky Sharp | Dec 31, 15:21 | |
| charlie | Dec 31, 15:23 |






Cocoa mail archive

