Select NSOutlineView programs programmatically (and select NSTableView)

I want to programmatically select OutlineViewin another class.

I can connect the instance NSOutlineViewto [[appDelegate outlineViewController] outlineView].

The idea behind this is that I have a view with a list of elements (which are also in outlineview) and I want the user to be able to click on the element in the view so that the selection of outlineviews is changed and thus a new view (of the selected item).

So, How can I change the software selection OutlineView?

If the question remains unclear, please let me know what I can do to make it more clear.

+5
source share
2 answers

If I understand you correctly, I think you're looking for a method NSOutlineView โ€“ selectRowIndexes:byExtendingSelection:. Note that NSOutlineViewis a subclass NSTableView.

+7
source

In my case,
I had NSTableViewwith elements from the list of "List of elements",
and OutlineView, like this:

  • Parent A
    • smth
    • smth
    • smth
    • .,.
  • Parent B
    • smth
    • smth
    • .,.
  • List of List Items
    • item1
    • item2
    • item3

Parent A and B are not important, but they are here to demonstrate that there is no fixed number of lines before the "list of items" view.

So what I did was that I used the - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
method in my delegate NSTableViewand in the method using NSTableView *tableView = [aNotification object];
NSInteger clickedRowInTableView = [tableView selectedRow];
to get the new highlighted line in mine tableView.

" " ( , , "" , ), " ", .

: clickedRowInTableView + rowNrOfItemsListView + 1, 1 " ".

NSOutlineView โ€“ selectRowIndexes:byExtendingSelection: ( Nate, ), OutlineView.

, , .

+2

All Articles