Re: NSView confusion
Re: NSView confusion
- Subject: Re: NSView confusion
- From: Andy Lee <email@hidden>
- Date: Wed, 20 Aug 2008 11:17:45 -0400
On Aug 20, 2008, at 10:25 AM, Charlie Dickman wrote:
Nobody has anything to offer other than a nebulous "try changing the
declarations"?
What's nebulous about that? It sounds like you are getting compiler
warnings that you can get rid of by using more specific declarations
for your view objects. If that is not the case, can you post the
exact messages the compiler is reporting?
Also, how does one synchronize events with the update of the various
views? I can instruct each view what to draw and it draws it just
fine (I use lockFocus, etc. when drawing is external to drawRect)
and the updated view is seen _eventually_ but I can not synchronize
subsequent activity to happen after the appropriate display is seen.
How can I accomplish this synchronization? And how can I force a
view to update? Invoking [view display] has no effect on forcing the
display toshow the latest update.
You mention that there is drawing done external to -drawRect:. Can
you explain why you are doing it this way? The normal pattern is for -
drawRect: to do all drawing for the view. It's up to your subclass to
know what that information is. -drawRect: gets called when some part
of your view's display area is invalidated, either by user action like
resizing the window, or programmatically like when you say [view
display].
If -drawRect: doesn't know how to draw everything it needs to draw,
you can call -display all day and nothing will happen. I suspect you
need to move the drawing logic that is currently outside -drawRect:
into -drawRect:, and possibly add one or more instance variables to
your view classes to represent the data that needs to be drawn.
By the way, note that it's -drawRect: (it takes an NSRect argument)
and not -drawRect.
You should review the View Programming Guide:
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/WhatAreViews/chapter_2_section_2.html
>
At some point you may want to look at the MVC pattern as well, since
you mentioned synchronizing drawing among different views.
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden