How to refresh detail view after [NSTreeController remove:sender]
How to refresh detail view after [NSTreeController remove:sender]
- Subject: How to refresh detail view after [NSTreeController remove:sender]
- From: Andy Triboletti <email@hidden>
- Date: Sat, 20 Jun 2009 11:30:33 -0400
I'm using the SourceView example project which is an NSTreeController
along with a detail view. I want to let the user remove the selected
item in the treecontroller by clicking on a delete button. I am using
NSTreeController remove:sender and the item is getting removed from
the list, and the selection moves down onto the next item in the
treecontroller. The problem I am having is that the detail view is
not getting refreshed after the remove is called. It is still showing
the detail of the deleted item until I move the selection with mouse
or keyboard.
I noticed that the 'result of this method is deferred until the next
iteration of the runloop', so what I did was try and schedule
something to run in the next run loop which would refresh the detail
view. Some code I am using is below, but no matter what I have tried
I can't get the detail view to refresh to the new item - it is still
showing the item that was just deleted unless I force a refresh by
clicking the mouse/keyboard.
- (void)deleteClick:(id)sender {
AppDelegate *appController = (AppDelegate *)[[NSApplication
sharedApplication] delegate];
[[[appController myWindowController] treeController] remove:sender];
[self performSelectorOnMainThread:@selector(delayedReaction:)
withObject:self waitUntilDone:NO];
}
- (void)delayedReaction:(id)sender {
AppDelegate *appController = (AppDelegate *)[[NSApplication
sharedApplication] delegate];
//trying a couple different ways to refresh the view here
[[appController myWindowController]
outlineViewSelectionDidChange:[appController myWindowController]];
[[appController myWindowController] changeItemView]; //changeItemView
removes the current subview and adds a new one based on what the
selected node is
[[appController myWindowController] refreshOutline];
}
Thanks for any help you can provide!
Andy Triboletti
_______________________________________________
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