Re: drawing into a hidden view
On May 15, 2010, at 11:50 AM, Shane wrote: I have an application which swaps NSViews based on which segment of an NSSegmentedControl the user clicks on. There's one specific NSView in which I draw a graph using NSBezierPath's. This view is initialized once my application is started and always exists, it's just not always the currently selected view. My problem is that, when this one specific NSView is not selected and the user runs a process, once the process completes the user selects the view and no updates are drawn into it. But if the NSView is currently selected, the view gets updates when data points are sent to it. Selected or not, I always send data points to it to be drawn. No you don't. You need them to be drawn when the view becomes visible. Drawing out-of-sight views is a waste of time and energy. When a view is added to a window and will be visible, it is marked as needing to be display, and is drawn. So if by swapping views you mean it is added as a subview of another view made visible, and removed when not, then you should already be covered. If by swapping you mean that you're simply switching selected tabs in a tab view and this graphing view is one of those tabs, then you're also taken care of. When a view's visible frame changes, it redraws. So the only way I can think of that this is happening, is that your data set isn't being set, and the view is still drawing the old content. That or something is calling setNeedsDisplay:NO. There's not really enough information here to go on. -- Seth Willits ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: drawing into a hidden view
On Sat, May 15, 2010 at 11:50 AM, Shane software.research.developm...@gmail.com wrote: I have nothing in my code that says if the view is not shown, don't draw into it. Anyone have ideas on what's happening? You need to dissociate drawing from data collection. Your view's implementation of -drawRect: should simply draw whatever the current state is. It might be something as simple as this: - (void)drawRect:(NSRect)dirtyRect { for (DataPoint *p in [modelObject dataPoints]) [self drawDataPoint:p]; } --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: drawing into a hidden view
You need to dissociate drawing from data collection. Your view's implementation of -drawRect: should simply draw whatever the current state is. It might be something as simple as this: - (void)drawRect:(NSRect)dirtyRect { for (DataPoint *p in [modelObject dataPoints]) [self drawDataPoint:p]; } But I have. My drawRect: is simply as follows. - (void) drawRect:(NSRect) rect { NSRect bounds = [self bounds]; [[NSColor blackColor] setFill]; [NSBezierPath fillRect:bounds]; [self drawAxes]; [self drawError]; return; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: drawing into a hidden view
On Sat, May 15, 2010 at 6:51 PM, Shane software.research.developm...@gmail.com wrote: But I have. My drawRect: is simply as follows. - (void) drawRect:(NSRect) rect { NSRect bounds = [self bounds]; [[NSColor blackColor] setFill]; [NSBezierPath fillRect:bounds]; [self drawAxes]; [self drawError]; return; } Okay, so then I don't understand why being offscreen is a problem. Unless you're for some reason expecting -drawRect: to be called when the view is offscreen? That's not gonna happen; you need to be drawing somewhere (screen, printing operation, offscreen window) in order for -drawRect: to get called. Once you bring the view back onscreen, -drawRect: will get called and it should draw your data. Maybe you have a logic error that prevents recording data under the same circumstances in which that view is offscreen? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com