提交 bd2a8b19 编写于 作者: J Joao Moreno

tree: expose shouldToggleExpansion

上级 b705856d
......@@ -170,7 +170,6 @@ export class DefaultController implements _.IController {
protected onLeftClick(tree: _.ITree, element: any, eventish: ICancelableEvent, origin: string = 'mouse'): boolean {
const payload = { origin: origin, originalEvent: eventish };
const event = <mouse.IMouseEvent>eventish;
const isDoubleClick = (origin === 'mouse' && event.detail === 2);
if (tree.getInput() === element) {
tree.clearFocus(payload);
......@@ -186,7 +185,7 @@ export class DefaultController implements _.IController {
tree.setSelection([element], payload);
tree.setFocus(element, payload);
if (this.openOnSingleClick || isDoubleClick || this.isClickOnTwistie(event)) {
if (this.shouldToggleExpansion(element, event, origin)) {
if (tree.isExpanded(element)) {
tree.collapse(element).done(null, errors.onUnexpectedError);
} else {
......@@ -198,6 +197,11 @@ export class DefaultController implements _.IController {
return true;
}
protected shouldToggleExpansion(element: any, event: mouse.IMouseEvent, origin: string): boolean {
const isDoubleClick = (origin === 'mouse' && event.detail === 2);
return this.openOnSingleClick || isDoubleClick || this.isClickOnTwistie(event);
}
protected setOpenMode(openMode: OpenMode) {
this.options.openMode = openMode;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册