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

split view: allow access to toolbar in header

上级 2d4a7483
......@@ -186,8 +186,10 @@ export enum CollapsibleState {
export class AbstractCollapsibleView extends HeaderView {
protected state: CollapsibleState;
private headerClickListener: () => void;
private headerKeyListener: () => void;
private focusTracker: dom.IFocusTracker;
constructor(opts: ICollapsibleViewOptions) {
super(opts);
......@@ -219,7 +221,19 @@ export class AbstractCollapsibleView extends HeaderView {
}
});
// Mouse access
this.headerClickListener = dom.addListener(this.header, dom.EventType.CLICK, () => this.toggleExpansion());
// Track state of focus in header so that other components can adjust styles based on that
// (for example show or hide actions based on the state of being focused or not)
this.focusTracker = dom.trackFocus(this.header);
this.focusTracker.addFocusListener(() => {
dom.addClass(this.header, 'focused');
});
this.focusTracker.addBlurListener(() => {
setTimeout(() => dom.removeClass(this.header, 'focused')); // delay to give other components a chance to react
});
}
public layout(size: number, orientation: Orientation): void {
......@@ -283,6 +297,11 @@ export class AbstractCollapsibleView extends HeaderView {
this.headerKeyListener = null;
}
if (this.focusTracker) {
this.focusTracker.dispose();
this.focusTracker = null;
}
super.dispose();
}
}
......
......@@ -52,7 +52,8 @@
display: none;
}
.monaco-workbench .viewlet .collapsible.header:hover .actions {
.monaco-workbench .viewlet .collapsible.header:hover .actions,
.monaco-workbench .viewlet .collapsible.header.focused .actions {
display: block;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册