【问题标题】:Spec - how to update a tree list keeping current selection?规范 - 如何更新保持当前选择的树列表?
【发布时间】:2022-01-17 10:18:53
【问题描述】:

我正在显示一棵树,我需要添加一个元素,但我想保留当前选定的项目。 如果我这样做:

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

它当然会起作用,但是有一个问题:激活事件(whenActivatedDo:)会被触发,我不这样做! 我怎样才能避免它?

【问题讨论】:

    标签: smalltalk pharo


    【解决方案1】:

    规范中的树和树表实现了 API updateRootsKeepingSelection: 以防止这种情况发生。
    实际操作和上面的代码是一样的,但是不会触发任何激活,也不会激活传输。

    这段代码:

    treePresenter updateRootsKeepingSelection: newRootCollection
    

    与原代码效果相同,但执行时不会触发激活。
    (当然,要正常工作需要新集合包含先前选择的元素)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-11
      • 2019-04-16
      • 1970-01-01
      • 2015-09-02
      相关资源
      最近更新 更多