Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 1.01 KB

qa003.md

File metadata and controls

28 lines (20 loc) · 1.01 KB

QA3 - how to update a tree list keeping current selection?

Q. I am displaying a tree and I need to add an element, but I want to keep the currently selected item.

If I do it like this:

oldSelectedItem := treePresenter selectedItem.
treePresenter
	roots: rootCollection;
	selectItem: oldSelectedItem

it will of course work, but there is a problem: the activation event (whenActivatedDo:) will be triggered and I do not what this! How can I proceed to avoid it?

A.

Trees and Tree tables in spec implement the API updateRootsKeepingSelection: to prevent precisely this.
In practice, it makes the same as the code above, but it will not trigger any activation, and no activation transmission.

This code:

treePresenter updateRootsKeepingSelection: rootCollection

Will have the same effect as the original code, but it will not trigger an activation when executed. (Of course, to work properly is required that the new collection contains the previously selected elements).