提交 ab5dce24 编写于 作者: B Benjamin Pasero

Up and down arrows should jump through splitview headers (fixes #2373)

上级 ddbb872c
......@@ -93,6 +93,10 @@ export class View extends ee.EventEmitter {
// to implement
}
public focus(): void {
// to implement
}
public layout(size: number, orientation: Orientation): void {
// to optionally implement
}
......@@ -223,6 +227,12 @@ export class AbstractCollapsibleView extends HeaderView {
} else if (event.equals(CommonKeybindings.ESCAPE)) {
this.header.blur();
eventHandled = true;
} else if (event.equals(CommonKeybindings.UP_ARROW)) {
this.emit('focusPrevious');
eventHandled = true;
} else if (event.equals(CommonKeybindings.DOWN_ARROW)) {
this.emit('focusNext');
eventHandled = true;
}
if (eventHandled) {
......@@ -245,6 +255,12 @@ export class AbstractCollapsibleView extends HeaderView {
});
}
public focus(): void {
if (this.header) {
this.header.focus();
}
}
public layout(size: number, orientation: Orientation): void {
this.layoutHeader();
super.layout(size, orientation);
......@@ -387,6 +403,8 @@ export class SplitView implements
private viewElements: HTMLElement[];
private views: View[];
private viewChangeListeners: lifecycle.IDisposable[];
private viewFocusPreviousListeners: lifecycle.IDisposable[];
private viewFocusNextListeners: lifecycle.IDisposable[];
private initialWeights: number[];
private sashOrientation: sash.Orientation;
private sashes: sash.Sash[];
......@@ -412,6 +430,8 @@ export class SplitView implements
this.viewElements = [];
this.views = [];
this.viewChangeListeners = [];
this.viewFocusPreviousListeners = [];
this.viewFocusNextListeners = [];
this.initialWeights = [];
this.sashes = [];
this.sashesListeners = [];
......@@ -475,6 +495,9 @@ export class SplitView implements
this.viewChangeListeners.splice(index, 0, view.addListener2('change', size => this.onViewChange(view, size)));
this.onViewChange(view, view.minimumSize);
this.viewFocusPreviousListeners.splice(index, 0, view.addListener2('focusPrevious', () => index > 0 && this.views[index - 1].focus()));
this.viewFocusNextListeners.splice(index, 0, view.addListener2('focusNext', () => index < this.views.length && this.views[index + 1].focus()));
}
public removeView(view: View): void {
......@@ -495,6 +518,12 @@ export class SplitView implements
this.viewChangeListeners[index].dispose();
this.viewChangeListeners.splice(index, 1);
this.viewFocusPreviousListeners[index].dispose();
this.viewFocusPreviousListeners.splice(index, 1);
this.viewFocusNextListeners[index].dispose();
this.viewFocusNextListeners.splice(index, 1);
this.views.splice(index, 1);
this.el.removeChild(this.viewElements[index]);
this.viewElements.splice(index, 1);
......
......@@ -361,7 +361,7 @@ export class AdaptiveCollapsibleViewletView extends FixedCollapsibleView impleme
return Promise.as(null);
}
public focus(): void {
public focusBody(): void {
focus(this.tree);
}
......@@ -488,7 +488,7 @@ export class CollapsibleViewletView extends CollapsibleView implements IViewletV
return Promise.as(null);
}
public focus(): void {
public focusBody(): void {
focus(this.tree);
}
......
......@@ -485,7 +485,7 @@ export class DebugViewlet extends viewlet.Viewlet {
super.focus();
if (this.views.length > 0) {
(<VariablesView>this.views[0]).focus();
(<VariablesView>this.views[0]).focusBody();
}
}
......
......@@ -116,9 +116,9 @@ export class ExplorerViewlet extends Viewlet {
super.focus();
if (this.explorerView) {
this.explorerView.focus();
this.explorerView.focusBody();
} else if (this.workingFilesView) {
this.workingFilesView.focus();
this.workingFilesView.focusBody();
}
}
......
......@@ -68,7 +68,7 @@ export class EmptyView extends CollapsibleView {
return Promise.as(null);
}
public focus(): void {
public focusBody(): void {
// Ignore
}
......
......@@ -196,8 +196,8 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
public focus(): void {
super.focus();
public focusBody(): void {
super.focusBody();
// Open the focused element in the editor if there is currently no file opened
let input = this.editorService.getActiveEditorInput();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册