From 1bdd7077a0000e0026e7605f32fefdfc9b720614 Mon Sep 17 00:00:00 2001 From: David Reis Date: Wed, 25 Sep 2019 20:05:38 +0100 Subject: [PATCH 1/3] Add support for touch events on the suggest widget --- src/vs/editor/contrib/suggest/suggestWidget.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/contrib/suggest/suggestWidget.ts b/src/vs/editor/contrib/suggest/suggestWidget.ts index 67ef86871c7c1..fa473303a9624 100644 --- a/src/vs/editor/contrib/suggest/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/suggestWidget.ts @@ -11,7 +11,7 @@ import { Event, Emitter } from 'vs/base/common/event'; import { onUnexpectedError } from 'vs/base/common/errors'; import { IDisposable, dispose, toDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle'; import { addClass, append, $, hide, removeClass, show, toggleClass, getDomNodePagePosition, hasClass, addDisposableListener, addStandardDisposableListener } from 'vs/base/browser/dom'; -import { IListVirtualDelegate, IListEvent, IListRenderer, IListMouseEvent } from 'vs/base/browser/ui/list/list'; +import { IListVirtualDelegate, IListEvent, IListRenderer, IListMouseEvent, IListTouchEvent } from 'vs/base/browser/ui/list/list'; import { List } from 'vs/base/browser/ui/list/listWidget'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; @@ -525,6 +525,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate this.onThemeChange(t))); this.toDispose.add(editor.onDidLayoutChange(() => this.onEditorLayoutChange())); this.toDispose.add(this.list.onMouseDown(e => this.onListMouseDown(e))); + this.toDispose.add(this.list.onTouchStart(e => this.onListTouchStart(e))); this.toDispose.add(this.list.onSelectionChange(e => this.onListSelection(e))); this.toDispose.add(this.list.onFocusChange(e => this.onListFocus(e))); this.toDispose.add(this.editor.onDidChangeCursorSelection(() => this.onCursorSelectionChanged())); @@ -572,6 +573,18 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate): void { + if (typeof e.element === 'undefined' || typeof e.index === 'undefined') { + return; + } + + // prevent stealing browser focus from the editor + e.browserEvent.preventDefault(); + e.browserEvent.stopPropagation(); + + this.select(e.element, e.index); + } + private onListMouseDown(e: IListMouseEvent): void { if (typeof e.element === 'undefined' || typeof e.index === 'undefined') { return; From dca80c5d87b7ce83cb7722fb50ce0698bc87a88b Mon Sep 17 00:00:00 2001 From: David Reis Date: Thu, 26 Sep 2019 11:09:53 +0100 Subject: [PATCH 2/3] Switched TouchStart event by GestureEvent (Tap) so that scrolling is possible on touch devices --- src/vs/editor/contrib/suggest/suggestWidget.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vs/editor/contrib/suggest/suggestWidget.ts b/src/vs/editor/contrib/suggest/suggestWidget.ts index fa473303a9624..7a95ee99d62b3 100644 --- a/src/vs/editor/contrib/suggest/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/suggestWidget.ts @@ -11,7 +11,7 @@ import { Event, Emitter } from 'vs/base/common/event'; import { onUnexpectedError } from 'vs/base/common/errors'; import { IDisposable, dispose, toDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle'; import { addClass, append, $, hide, removeClass, show, toggleClass, getDomNodePagePosition, hasClass, addDisposableListener, addStandardDisposableListener } from 'vs/base/browser/dom'; -import { IListVirtualDelegate, IListEvent, IListRenderer, IListMouseEvent, IListTouchEvent } from 'vs/base/browser/ui/list/list'; +import { IListVirtualDelegate, IListEvent, IListRenderer, IListMouseEvent, IListGestureEvent } from 'vs/base/browser/ui/list/list'; import { List } from 'vs/base/browser/ui/list/listWidget'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; @@ -525,7 +525,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate this.onThemeChange(t))); this.toDispose.add(editor.onDidLayoutChange(() => this.onEditorLayoutChange())); this.toDispose.add(this.list.onMouseDown(e => this.onListMouseDown(e))); - this.toDispose.add(this.list.onTouchStart(e => this.onListTouchStart(e))); + this.toDispose.add(this.list.onTap(e => this.onListTap(e))); this.toDispose.add(this.list.onSelectionChange(e => this.onListSelection(e))); this.toDispose.add(this.list.onFocusChange(e => this.onListFocus(e))); this.toDispose.add(this.editor.onDidChangeCursorSelection(() => this.onCursorSelectionChanged())); @@ -573,7 +573,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate): void { + private onListTap(e: IListGestureEvent): void { if (typeof e.element === 'undefined' || typeof e.index === 'undefined') { return; } From 2e88aaf19efde68f0f52ddfbf92eaa3e0c9d445b Mon Sep 17 00:00:00 2001 From: David Reis Date: Thu, 26 Sep 2019 18:25:11 +0100 Subject: [PATCH 3/3] Renamed onListMouseDown and onListTap functions to onListMouseDownOrTap in SuggestWidget --- src/vs/editor/contrib/suggest/suggestWidget.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/vs/editor/contrib/suggest/suggestWidget.ts b/src/vs/editor/contrib/suggest/suggestWidget.ts index 7a95ee99d62b3..418d07d5b57c8 100644 --- a/src/vs/editor/contrib/suggest/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/suggestWidget.ts @@ -524,8 +524,8 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate this.onThemeChange(t))); this.toDispose.add(editor.onDidLayoutChange(() => this.onEditorLayoutChange())); - this.toDispose.add(this.list.onMouseDown(e => this.onListMouseDown(e))); - this.toDispose.add(this.list.onTap(e => this.onListTap(e))); + this.toDispose.add(this.list.onMouseDown(e => this.onListMouseDownOrTap(e))); + this.toDispose.add(this.list.onTap(e => this.onListMouseDownOrTap(e))); this.toDispose.add(this.list.onSelectionChange(e => this.onListSelection(e))); this.toDispose.add(this.list.onFocusChange(e => this.onListFocus(e))); this.toDispose.add(this.editor.onDidChangeCursorSelection(() => this.onCursorSelectionChanged())); @@ -573,19 +573,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate): void { - if (typeof e.element === 'undefined' || typeof e.index === 'undefined') { - return; - } - - // prevent stealing browser focus from the editor - e.browserEvent.preventDefault(); - e.browserEvent.stopPropagation(); - - this.select(e.element, e.index); - } - - private onListMouseDown(e: IListMouseEvent): void { + private onListMouseDownOrTap(e: IListMouseEvent | IListGestureEvent): void { if (typeof e.element === 'undefined' || typeof e.index === 'undefined') { return; }