Re: NSView redisplay - what am I missing?
Re: NSView redisplay - what am I missing?
- Subject: Re: NSView redisplay - what am I missing?
- From: Bob Ippolito <email@hidden>
- Date: Wed, 25 May 2005 00:14:02 -0700
On May 24, 2005, at 11:55 PM, Dragan Milić wrote:
can someone please explain me this strange behavior: I've created
my custom NSView (actually NSControl) class, which shows some items
and other stuff. When an application crunches some data (in
separate thread), that views is constantly being updated, by
talking to its dataSource object, which in turns supply newly
created items and at the end, the whole view is redisplayed, by
sending -setNeedsDisplay: message to itself. And that's OK. In the
same window, there is NSProgressIndicator instance, which shows how
data crunching is progressing and its value is updated much more
frequently than the custom view is redisplayed. But somehow,
"someone" is sending - setNeedsDisplay: to my view, even if there's
no new item to show. Just as NSProgressIndicator is being updated,
my view enters its -drawRect: method. I confirmed that by putting
log message inside that method. Now, that's happening when creating
custom view programatically. If I instantiate it in IB (I defined -
initWithCoder: method, which looks exactly the same as -
initWithFrame: for programatic creation, except for different
message sent to super, of course), my custom view behaves just
right, no superfluous redisplaying. The sole reason I create it
programatically is to put it inside NSScrollView instantiated in
IB, since I've been to lazy to create separate IB palette which
includes NSScrollView as well. I can easily solve this problem by
instantiating the view in IB, but I'm really curious whether I'm
missing something. I 'd like to know what might be the reason for
superfluous redisplaying when creating view programatically.
Sounds like you're not following the threading rules. You can't call
setNeedsDisplay: from your thread, it needs to be done on the main
thread. Threading and drawing has come up like three times this
week, I suggest searching the archives.
http://developer.apple.com/documentation/Cocoa/Conceptual/
Multithreading/index.html
-bob
_______________________________________________
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