> In article <3F447179.81983E21nospam.idiom.com>, John C. Randolph
> <jcrnospam.idiom.com> wrote:
> > Steve Ketcham wrote:
> > >
> > > I've created my own subclass of NSView -- call it myView. In it, I
> > > create an NSMatrix that I sometimes update. When the update is
> > > necessary, as signalled by a button click reported to another class, I
> > > send [myView setNeedsDisplay:YES] to my subclass, expecting drawRect:
> > > to be called.
> > >
> > > But it isn't.
> > >
> > > I've found that if I send [[myView superview] setNeedsDisplay:YES],
> > > everything works as I'd expect - myView's drawRect: is called, and the
> > > NSMatrix gets updated.
> > >
> > > But it bothers me: it seems to me that I shouldn't need to interact
> > > with the superview. Am I confused, or have I left something out of
> > > myView?
> > It sounds like you're never sending -setNeedsDisplay: to the NSMatrix.
> > -jcr
> Here's the view hierarchy:
> If I send -setNeedsDisplay: to the NSTabView, the matrix is
> redisplayed. If I send it to myView, it isn't. How does the NSTabView
> send the message to the NSMatrix?
> Are you telling me that I should implement -setNeedsDisplay: in myView
> to pass the message to the NSMatrix? (I can't send it directly from
> the controller class: that class knows about myView, but not its
> components.) If so, that isn't what the doentation says. It says
> that a -setNeedsDisplay message sent to an NSView causes its entire
> bounds to be redisplayed. Since its "entire bounds" contains its
> subviews, shouldn't they get redrawn automatically, too?
> Moreover, I'm not even sure it would work. myView's -drawRect:
> changes the cells in the matrix, so redrawing the existing matrix
> wouldn't help.
> The question really comes down to this: why doesn't [myView
> setNeedsDisplay:YES] result in a call to myView's drawRect:?
> From the description of NSView's -setNeedsDisplay: at
> "If flag is YES , marks the receiver1s entire bounds as needing
> display; if flag is NO , marks it as not needing display. Whenever the
> data or state used for drawing a view object changes, the view should
> be sent a setNeedsDisplay: message. NSViews marked as needing display
> are automatically redisplayed on each pass through the application1s
> event loop."
> My NSView subclass isn't being redrawn, because drawRect: is never
> I guess I'm still confused.