|
From: Dave H. <gr...@gr...> - 2006-02-10 22:49:04
|
I have an outline display, with a convenient "+" button nearby. When I
click the +, I want a new item to appear "underneath" my currently
selected row, the current row to expand to expose the new item, and to
select the new item.
I create the new item just fine, but I can't select the new thing
because I can't expand the old thing. I can't expand the old thing
because Cocoa doesn't know that it's expandable yet.
*IF* it already had an item underneath it, collapsed or not, then
everything works find. It's only when it isn't an expandable item when
I start that I get stuck.
currentItem = @outlineView.itemAtRow(@outlineView.selectedRow)
currentProject = Project.index(currentItem.to_i)
newProject = currentProject.newProject('Unnamed')
[I'm not passing Ruby objects to the outlineView, just ID numbers.) If
I now ask
@outlineView.isExpandable(currentItem)
it's "false," no surprise there. Specifically, it's "0". If I try to
update the view, things actually get worse....
@outlineView.reloadItem(currentItem)
@outlineView.isExpandable(currentItem)
Now the answer's "-1". "reloadItem" sets "needsDisplay" on the view,
and it appears that "-1" is code for "this view's current status is not
known."
OK, fine.
self.window.display
Nope, doesn't help. Nothing happens until my entire little method has
completed. The reload and display doesn't actually happen until Cocoa
walks back through the input event loop, which it doesn't do until my
code is done executing. :/ How can I get my code to *wait* until the
reload/refresh/update/display has actually occurred? Or put another
way, how can I get Cocoa to NOT wait to update the display? I don't
know where to look for that sort of thing.
|