NSOutlineView NSTableRowView Loses Apparent Selection After Editing - macos

I have a view-based outline view (OSX 10.7). Clicking on an item selects it, as usual. Double clicking allows editing of the textfield it contains. However, when I'm done editing the textField, the row's highlight disappears. The outlineView still thinks the row is selected, and sending that row a drawSelectionInRect message doesn't change its appearance. Telling the outlineView to again select the row also doesn't change its appearance. Only by again clicking on the row can I get the highlight to reappear. Any idea what's going on?

My fault. I'm observing changes to the managedObjectContext, and was reloading the entire tree when individual items changed: by correcting this to reload only the affected item, things work as they should.

Related

NSTableView editable cell deselects edit more randomly

I have a cell-based NSTableView with an editable text field. Sometimes, seemingly randomly, after choosing to edit the field and typing a few characters, the field exits edit mode and I am left unable to edit the value.
Closing the document and reopening fixes it for a while.
What might be causing this?
It is bound to an NSArrayController and I believe that NSConditionallySetsEditableBindingOption is true by default.

How to disable unselect row in NSOutlineView

I have NSOutlineView and I don't know how to disable unselect row in it. It's problem when I click into NSOutlineView where isn't any cell, selected row is unselected. Is there any way, how to keep selected row when someone click into NSOutlineView? But It has to work normally when someone click onto other cell. Thanks.
In Interface Builder go to the Attribute inspector, under the Table View section make sure Empty is not checked.

NSTrackingArea in tableview issue

I have set up my table view to work kinda like the Twitter app meaning when you hover over each row icons will appear on the right side and when leaving the row they will disappear. I coded it based upon this:
mouseExited isn't called when mouse leaves trackingArea while scrolling
The very strange thing is I have a checkbox on each row (along with other text fields, etc.) and when clicking the checkbox it causes the icons for that row to jump to the next row. Clicking the checkbox again will cause them to jump to the next row. This repeats until the icons jump to the last visible row then they will jump to the first visible row and keep repeating this behavior. And it happens only sometimes. :-/ I tried to figure this out but nothing is even being called when this happens meaning no call to tracking areas or mouse entered/exited nothing. Does this make any sense at all and maybe considering I'm trying to recreate how Twitter does it did I code it wrong?
Thanks,
rc

NSTableView how to click anywhere in the cell to edit text?

I have a very simple NSTableView hooked up via NSArrayController and bindings to my model. I would like to tweak the behaviour the of the view slightly when double clicking to edit. It seems the default behaviour for when double click editing a cell is to only open the cell for editing when the click happens on the location of text inside the cell (see below).
I would like to change the behaviour so that a double click anywhere in the cell causes editing (the green case in the image below). Any ideas? Maybe I was searching for the wrong terms but I couldn't find anything out there about this.
Subclass NSTextFieldCell and override -hitTestForEvent:inRect:ofView: to return NSCellHitEditableTextArea regardless of where the mouse click occurred.

How do I check if a NSView is being displayed at the moment?

I got an application which has a NSToolbar in its main window. Depending on which icon is clicked a NSView is displayed in this window. My problem is, that one of these views shows data in a NSTableView that I want to be reloaded each time the view is visible. Since -init is only called once, I don't know how to do that.
(example: When the application starts it shows the Documents section [on of the sub views of the window]. Now when I click on Employees [which displays another sub view instead of the first one] and then on Documents again, I want the data in Documents' NSTableView to reload.)
How do I do that?
Thanks in advance.
I got an application which has a NSToolbar in its main window. Depending on which icon is clicked a NSView is displayed in this window.
Use a tab view. You can hide the tabs, then implement your action methods for the toolbar items to act as the tabs, changing the selected tab view item to whichever one corresponds to the pressed toolbar item.
Now when I click on Employees [which displays another sub view instead of the first one] and then on Documents again, I want the data in Documents' NSTableView to reload.
Why? Why not reload it only when the data changes?
You don't have to hold NSTableView's hand; if it needs the data from you again, it'll ask you for it again.
And if you're concerned about reloading the data while the view is not visible, that's premature optimization. Don't worry about it until you prove via profiling that it is a real performance problem.

Resources