Re: Do bindings "pay attention" to visibility of control?
Re: Do bindings "pay attention" to visibility of control?
- Subject: Re: Do bindings "pay attention" to visibility of control?
- From: Ricky Sharp <email@hidden>
- Date: Mon, 5 Dec 2005 16:03:30 -0600
On Dec 5, 2005, at 2:20 PM, Andrei Tchijov wrote:
For example, in my application I have Tabless NSTabView with each
tab holding "details" view for different kind of object from
"master" list of objects. Obviously, only one tab is visible at a
time. And more importantly, only bindings from currently visible
tab "make sense" for currently selected object from "master"
list. Will bindings try to keep fields from "invisible" tabs up to
date or not?
On Dec 5, 2005, at 1:27 PM, Daniel Jalkut wrote:
If you think about how bindings work, it would be very difficult
for them to avoid updating UI items when they were hidden. The
problem is this: if you don't update it now (when the value has
actually changed), when do you update it? It would be a shame to
have a bunch of controls off-screen and then when they're made
visible they either no longer have valid values or all have to
manually update from the model.
Since the "pushing to the UI" component is based on key-value
observing, there's really no other time to be notified of the
change than when the change occurs. If you wanted to avoid this
for some reason I suppose you could manually unbind all the
controls while they are hidden and then rebind them when they
become visible.
I wouldn't avoid it. I use tabless tabviews quite a bit and it's
nice to have them all up-to-date when they are brought into view. I
have found no performance hits at all. One thing I do though is keep
my setters very lightweight. Beyond setting the value, they at most
just trip flags (e.g. setNeedsDisplay:, setNeedsCreateCachedImage:).
The drawXXX method is where the expensive operations occur (e.g.
recreating a cached image). But those will be NOP if the view is
hidden.
If you find that your setters are doing very expensive operations,
you may want to consider postponing the work until a later point if
possible. And, only perform the work when you're visible.
___________________________________________________________
Ricky A. Sharp
mailto:email@hidden
Instant Interactive(tm)
http://www.instantinteractive.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden