From 01f1c630fd3b2e70e531dfbcd26ff5f905c5fea0 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 30 Jan 2022 17:16:00 +0100 Subject: [PATCH] inspector: code editor: prevent issue on middle click --- src/client/ui/ui-inspector-field.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/ui/ui-inspector-field.js b/src/client/ui/ui-inspector-field.js index fbe807a7..ed993c99 100644 --- a/src/client/ui/ui-inspector-field.js +++ b/src/client/ui/ui-inspector-field.js @@ -191,9 +191,19 @@ class UiInspectorField extends UiWidget { editor.selection.setRange({start:0,end:0}) editor.gotoLine(0) editor.removeAllListeners('focus') + editor.removeAllListeners('mousedown') + editor.removeAllListeners('mouseup') editor.setOptions({maxLines: 30}) editor.dirty = false - editor.on('focus', ()=>{ + editor.middledown = false + editor.on("mousedown", function (e) { + if (e.domEvent.button === 1) editor.middledown = true + }) + editor.on("mouseup", function (e) { + if (e.domEvent.button === 1) editor.middledown = false + }) + editor.on('focus', (e)=>{ + if (editor.middledown) return this.parent.focusedInput = input editor.setHighlightActiveLine(true) editor.setHighlightGutterLine(true) @@ -278,7 +288,7 @@ class UiInspectorField extends UiWidget { var fullscreenBtn = this.container.appendChild(html`
${raw(icon('expand'))}
`) fullscreenBtn.addEventListener('fast-click', (e)=>{ - // update dom reference because we might break them with morph in ui-inspector.js + // update dom reference because we might break them with morph in ui-inspector.js this.container = e.target.closest('osc-inspector-field') this.label = DOM.get(this.container, 'label')[0]