Re: NSTextField refreshes are wacky.
Re: NSTextField refreshes are wacky.
- Subject: Re: NSTextField refreshes are wacky.
- From: email@hidden
- Date: Tue, 12 Mar 2002 02:46:43 -0800
You don't say so, but it sounds to me like you have somehow changed
the background of the textfield to not draw, or to draw in a color
that is transparent. In this case, you need to make sure that
-isOpaque is returning NO for your now non-opaque textfield.
Are you sure?
My code never subclasses NSTextField and the "draws background" switch
is always turned off. All works excellent.
That may work fine; sounds like it does. I wonder if setting a
background color that is less than opaque also works fine automatically,
though...? Certainly if he's doing any sort of override of the
textfield's drawing behavior to disable its background fill, things
would break if he didn't also override -isOpaque to return NO.
I didn't say he necessarily needed to override -isOpaque to return NO;
I said he needed to make sure it was returning NO as it ought to, if his
textfield was in fact transparent. I suspect you'll find, if you check,
that NSTextField is returning NO for you in your case, and so it just
works.
The -isOpaque thing is an performance improvement as it disallows
transparent parts in the Buttons images and enhances rendering
performance at this price.
Right. And it sounds like the system is acting as if it considers the
textfield to be opaque, when in fact it is not. He was saying that
previous versions of the string would fail to get erased, but only
sometimes. This is precisely the behaviour one would expect from a
transparent textfield that claimed to be opaque.
The reason is that views that claim to be opaque are expected to erase
their own background area; if they call -setNeedsDisplay:YES, their
superview will usually not be asked to draw in the invalidated area
first. Controls that are transparent will always have their superview
draw first, because they have notified the AppKit that their superview's
content may show through.
So a view that is not opaque, but claims to be, will be asked to draw
itself when there is old garbage in the window buffer in the area it's
going to draw. The superview will not be asked to draw itself first,
because the system is assuming the view will erase itself thoroughly,
like a good opaque view. If it fails to do so, old content will remain
visible.
As for Johnathan's original question, he probably simply messed
something up like he accidently duplicated the text field in IB or so.
That's a possibility too. But with the way everybody on this list
seems to be crazy about making textfields and textviews transparent, my
mind leapt in that direction, perhaps precipitously. :->
There are tons of examples where he can look at, including the
CurrencyConverter Tutorial.
Of course, none of them are specifically examples of how to fix the
problem he was experiencing... :->
Ben Haller
Stick Software
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.