diff --git a/src/ts/RemoteCursorManager.ts b/src/ts/RemoteCursorManager.ts index 13e2cb5..3d10649 100644 --- a/src/ts/RemoteCursorManager.ts +++ b/src/ts/RemoteCursorManager.ts @@ -24,7 +24,7 @@ export interface IRemoteCursorManagerOptions { editor: monaco.editor.ICodeEditor; /** - * Determines if tooltips will be shown when the cursor is moved. + * Determines if tooltips will be shown when the cursor is moved or hovered. */ tooltips?: boolean; @@ -33,6 +33,11 @@ export interface IRemoteCursorManagerOptions { * it was last moved. */ tooltipDuration?: number; + + /** + * Show the tooltip when the cursor is hovered + */ + showTooltipOnHover?: boolean; } /** @@ -120,6 +125,7 @@ export class RemoteCursorManager { label, this._options.tooltips, tooltipDurationMs, + this._options.showTooltipOnHover, () => this.removeCursor(id)); this._cursorWidgets.set(id, cursorWidget); diff --git a/src/ts/RemoteCursorWidget.ts b/src/ts/RemoteCursorWidget.ts index d5a2897..1b5685f 100644 --- a/src/ts/RemoteCursorWidget.ts +++ b/src/ts/RemoteCursorWidget.ts @@ -55,6 +55,7 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable { label: string, tooltipEnabled: boolean, tooltipDuration: number, + showTooltipOnHover: boolean, onDisposed: OnDisposed) { this._editor = codeEditor; this._tooltipDuration = tooltipDuration; @@ -81,6 +82,16 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable { this._scrollListener = this._editor.onDidScrollChange(() => { this._updateTooltipPosition(); }); + + if (showTooltipOnHover) { + this._domNode.style.pointerEvents = 'auto'; + this._domNode.addEventListener('mouseover', () => { + this._setTooltipVisible(true); + }) + this._domNode.addEventListener('mouseout', () => { + this._setTooltipVisible(false); + }) + } } else { this._tooltipNode = null; this._scrollListener = null;