 |
 |
TextView with transparent background?
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 2000
Status:
Offline
|
|
Hello ...
I want my NSTextView to have a transparent background. I've tried assigning a zero-percent-opacity color to the background in IB, and I've tried sending "setDrawsBackground:NO" to the view programmatically. No matter what I do, the text view's background displays window-striping, but the placement of the view makes the stripes out of phase with the window's own stripes, which is just ugly.
I note that in IB, the stripes are perfectly aligned and the background is wonderfully transparent. When the program runs, the stripes get mis-aligned. (Even when the stripes are aligned, I can still --but just barely-- perceive the view's rectangle.)
How do I get an honest-to-goodness *not-visible* background in a NSTextView?
Thanks and regards,
DayLate Don
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
Hmm... perhaps you need to subclass NSTextView, NSScrollView, or NSClipView and override <font face = "courier">isOpaque</font> to return NO. Dunno if it'll work...
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Mar 2000
Status:
Offline
|
|
you need to setup the window and the views. something like this should do it:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
<font color = brown>//Set the background color to clear</font>
[[self window] setBackgroundColor: [NSColor clearColor]];
<font color = brown>//set the transparency close to one.</font>
[[self window] setAlphaValue: <font color = blue>0.9999</font>];
[[self window] setOpaque: NO];
[scrollView setDrawsBackground: NO];
[textView setDrawsBackground: NO];
</font>[/code]
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Mar 2000
Status:
Offline
|
|
<error>
[ 04-21-2002: Message edited by: nibs ]
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 2000
Status:
Offline
|
|
Hello ...
I found the trouble. I have to send "setDrawsBackground:NO" to the NSScrollView containing the NSTextView.
That is sending
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
[[myTextView superview] superview] setDrawsBackground:NO];
</font>[/code]
does the trick. ( [myTextView superview] is the NSClipView; the second 'superview' gets me out to the NSScrollView level.)
It turns out that I have to send this to every scrolly object in my app (for instance a scrolling matrix of buttons). Hopefully Apple will provide a "Draws Background" checkbox to the NSScrollView info palette in Interface Builder. (And the same checkbox for NSTextView, which passes its value up to the scroll view.) The double-superview call raises (now numerous) Project Builder warnings that NSView doesn't understand "setDrawsBackground:".
Is there a way to tell Project Builder not to throw out that warning each time?
Thanks,
DayLateDon
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status:
Offline
|
|
Originally posted by DayLateDon:
<STRONG>Is there a way to tell Project Builder not to throw out that warning each time?
Thanks,
DayLateDon</STRONG>
Cast it to the appropriate type as so:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
[(NSScrollView*)[myTextView superview] superview] setDrawsBackground:NO];
</font>[/code]
HTH,
F-bacher
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 2000
Status:
Offline
|
|
Hello ...
"Cast it to the appropriate type" ... Of course!
(slaps self on forehead)
Thanks ...
DayLateDon
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|