Re: NSView redisplay - what am I missing?
Re: NSView redisplay - what am I missing?
- Subject: Re: NSView redisplay - what am I missing?
- From: Dragan Milić <email@hidden>
- Date: Thu, 26 May 2005 00:36:28 +0200
Yes, you're right, after posting my question this morning, I've read some more documentation, and eventually found out that an observer catches and reacts upon notification in the same thread it's been posted. But that actually has nothing to do with my problem, or at least I think so. And after reading, checking and trying all day long, I still haven't found the answer. This is the whole (a little longer) story.
I've made my custom NSControl class and it actually works fine. Before I continue, I should say that I'm not very experienced Cocoa programmer, especially when creating custom views/controls, this is my first serious one. Now, I've put my custom control on the main window, together with some others simple controls (NSProgressIndicator and NSTextField). When I update these simple controls by setting their values (set accessors), not by sending them -setNeedsDisplay: message (from the separate thread, as i know now) by posting appropriate notifications, my view reacts also and gets redrawn (enters its -drawRect: method), but only if created programatically, everything is OK when instantiating it in IB. I mistakenly thought that it has something to do with that instantiation, but after playing around today, I saw that's not the case. Namely, when instantiating from IB, I've put only my control on the window, but when creating it programatically, I've put it in enclosing NSScrollView instance. And that's the "problem". When it's in scroll view, "something" sends drawRect: message to my control, or setting it as needed display, when the other controls on the window are to be updated/redrawn. After playing around a little bit more, I discovered that in those situations enclosing scroll view DOES NOT redraw itself (it doesn't enter its -drawRect: method), but enclosing NSClipView instance DOES SO!. It enters -drawRect: immediately before my custom control does so, so I suppose redrawing of my control is part of clipViews' redrawn process. Now I wonder, what sets enclosing NSClipView as needing redisplay, when I only set values of other controls, I'm not resizing my view (enclosed documentView) nor window, or change its contents/attributes in any possible way.
This is not a big problem, it doesn't affect my app that much, but I'd like to know what's going on, maybe I'm missing some important feature of Cocoa internals, and I surely don't want that :-)
Cheers,
Milke
On 25.
мај 2005., at 22:05, Clark Cox wrote:
On 5/25/05, Dragan Milić <email@hidden> wrote:
Well, I'm just doing what I've been doing before, and I'm not calling
-setNeedsDisplay: from my thread. The separate thread deals with data
processing. When certain amount of processing is done, an notification
(let's call it note1) is posted and, window controller is responsible
to catch it and update user interface (progress bar) in the main
thread.
How are you posting this notification. Are you using
NSNotificationCenter? If so, then you really *are* trying to update
the UI from your secondary thread.
--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
_______________________________________________
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