From dcc563a7e92aaf778498f4270d83a012a8f37f9d Mon Sep 17 00:00:00 2001 From: Christopher Leidigh Date: Wed, 27 Dec 2017 18:09:51 -0500 Subject: [PATCH] :christmas_tree: SelectBox: First character navigation (#40874) --- .../browser/ui/selectBox/selectBoxCustom.ts | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/vs/base/browser/ui/selectBox/selectBoxCustom.ts b/src/vs/base/browser/ui/selectBox/selectBoxCustom.ts index 472557cea13..75a2275600c 100644 --- a/src/vs/base/browser/ui/selectBox/selectBoxCustom.ts +++ b/src/vs/base/browser/ui/selectBox/selectBoxCustom.ts @@ -8,7 +8,7 @@ import 'vs/css!./selectBoxCustom'; import * as nls from 'vs/nls'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import Event, { Emitter, chain } from 'vs/base/common/event'; -import { KeyCode } from 'vs/base/common/keyCodes'; +import { KeyCode, KeyCodeUtils } from 'vs/base/common/keyCodes'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import * as dom from 'vs/base/browser/dom'; import * as arrays from 'vs/base/common/arrays'; @@ -161,20 +161,12 @@ export class SelectBoxList implements ISelectBoxDelegate, IDelegate { - dom.EventHelper.stop(e); - })); - this.toDispose.push(dom.addDisposableListener(this.selectElement, dom.EventType.MOUSE_DOWN, (e) => { dom.EventHelper.stop(e); })); // Intercept keyboard handling - this.toDispose.push(dom.addDisposableListener(this.selectElement, dom.EventType.KEY_UP, (e: KeyboardEvent) => { - dom.EventHelper.stop(e); - })); - this.toDispose.push(dom.addDisposableListener(this.selectElement, dom.EventType.KEY_DOWN, (e: KeyboardEvent) => { const event = new StandardKeyboardEvent(e); let showDropDown = false; @@ -195,10 +187,6 @@ export class SelectBoxList implements ISelectBoxDelegate, IDelegate { - dom.EventHelper.stop(e); - })); } public get onDidSelect(): Event { @@ -490,6 +478,7 @@ export class SelectBoxList implements ISelectBoxDelegate, IDelegate e.keyCode === KeyCode.Escape).on(e => this.onEscape(e), this, this.toDispose); onSelectDropDownKeyDown.filter(e => e.keyCode === KeyCode.UpArrow).on(this.onUpArrow, this, this.toDispose); onSelectDropDownKeyDown.filter(e => e.keyCode === KeyCode.DownArrow).on(this.onDownArrow, this, this.toDispose); + onSelectDropDownKeyDown.filter(e => (e.keyCode >= KeyCode.KEY_0 && e.keyCode <= KeyCode.KEY_Z) || (e.keyCode >= KeyCode.US_SEMICOLON && e.keyCode <= KeyCode.NUMPAD_DIVIDE)).on(this.onCharacter, this, this.toDispose); // SetUp list mouse controller - control navigation, disabled items, focus @@ -596,6 +585,23 @@ export class SelectBoxList implements ISelectBoxDelegate, IDelegate