0

我有一个用 XUL 编写的应用程序,其中包含一个包含许多项目的自定义树视图。我有一个允许删除所选项目的按钮,但我的问题是,每当按下此按钮时,树都会一直滚动到顶部。我试图通过重新选择旧索引处的项目来解决这个问题,但不幸的是这不会滚动视图。有没有办法让树视图不滚动到顶部或强制它重新滚动回原始位置?

我的代码看起来像这样:

onRemoveNilSelection: function(event) {
  var selectedIndex = this._tree.currentIndex;
  this._treeView.removeItem(selectedIndex);
  this._tree.view = this._treeView;
  this._treeView.selection.select(selectedIndex);
},
4

1 回答 1

3

使用boxObject 的 scrollToRow() 函数

如果你的树在 this._tree 上,

this._tree.boxObject.scrollToRow(selectedIndex);
于 2009-05-09T15:44:57.083 回答