提交 b8e63912 编写于 作者: A Alex Dima

Improve handling of modifier only key presses in define keybinding widget

上级 b7da8414
......@@ -514,6 +514,18 @@ export class SimpleKeybinding {
|| this.keyCode === KeyCode.Shift
);
}
/**
* Does this keybinding refer to the key code of a modifier and it also has the modifier flag?
*/
public isDuplicateModifierCase(): boolean {
return (
(this.ctrlKey && this.keyCode === KeyCode.Ctrl)
|| (this.shiftKey && this.keyCode === KeyCode.Shift)
|| (this.altKey && this.keyCode === KeyCode.Alt)
|| (this.metaKey && this.keyCode === KeyCode.Meta)
);
}
}
export class ChordKeybinding {
......
......@@ -36,14 +36,14 @@ export class ModifierLabelProvider {
}
public toLabel(firstPartMod: Modifiers, firstPartKey: string, chordPartMod: Modifiers, chordPartKey: string, OS: OperatingSystem): string {
if (!firstPartKey && !chordPartKey) {
if (firstPartKey === null && chordPartKey === null) {
return null;
}
return _asString(firstPartMod, firstPartKey, chordPartMod, chordPartKey, this._labels[OS]);
}
public toHTMLLabel(firstPartMod: Modifiers, firstPartKey: string, chordPartMod: Modifiers, chordPartKey: string, OS: OperatingSystem): IHTMLContentElement[] {
if (!firstPartKey && !chordPartKey) {
if (firstPartKey === null && chordPartKey === null) {
return null;
}
return _asHTML(firstPartMod, firstPartKey, chordPartMod, chordPartKey, this._labels[OS]);
......@@ -139,7 +139,7 @@ export const UserSettingsLabelProvider = new ModifierLabelProvider(
);
function _simpleAsString(modifiers: Modifiers, key: string, labels: ModifierLabels): string {
if (!key) {
if (key === null) {
return '';
}
......@@ -171,7 +171,7 @@ function _simpleAsString(modifiers: Modifiers, key: string, labels: ModifierLabe
function _asString(firstPartMod: Modifiers, firstPartKey: string, chordPartMod: Modifiers, chordPartKey: string, labels: ModifierLabels): string {
let result = _simpleAsString(firstPartMod, firstPartKey, labels);
if (chordPartKey) {
if (chordPartKey !== null) {
result += ' ';
result += _simpleAsString(chordPartMod, chordPartKey, labels);
}
......@@ -194,7 +194,7 @@ function _pushKey(result: IHTMLContentElement[], str: string, append: string): v
}
function _simpleAsHTML(result: IHTMLContentElement[], modifiers: Modifiers, key: string, labels: ModifierLabels): void {
if (!key) {
if (key === null) {
return;
}
......@@ -223,7 +223,7 @@ function _asHTML(firstPartMod: Modifiers, firstPartKey: string, chordPartMod: Mo
let result: IHTMLContentElement[] = [];
_simpleAsHTML(result, firstPartMod, firstPartKey, labels);
if (chordPartKey) {
if (chordPartKey !== null) {
result.push({
tagName: 'span',
text: ' '
......
......@@ -49,21 +49,41 @@ export class USLayoutResolvedKeybinding extends ResolvedKeybinding {
return KeyCodeUtils.toString(keyCode);
}
private _getUILabelForKeybinding(keybinding: SimpleKeybinding): string {
if (!keybinding) {
return null;
}
if (keybinding.isDuplicateModifierCase()) {
return '';
}
return this._keyCodeToUILabel(keybinding.keyCode);
}
public getLabel(): string {
let firstPart = this._firstPart ? this._keyCodeToUILabel(this._firstPart.keyCode) : null;
let chordPart = this._chordPart ? this._keyCodeToUILabel(this._chordPart.keyCode) : null;
let firstPart = this._getUILabelForKeybinding(this._firstPart);
let chordPart = this._getUILabelForKeybinding(this._chordPart);
return UILabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._os);
}
private _getAriaLabelForKeybinding(keybinding: SimpleKeybinding): string {
if (!keybinding) {
return null;
}
if (keybinding.isDuplicateModifierCase()) {
return '';
}
return KeyCodeUtils.toString(keybinding.keyCode);
}
public getAriaLabel(): string {
let firstPart = this._firstPart ? KeyCodeUtils.toString(this._firstPart.keyCode) : null;
let chordPart = this._chordPart ? KeyCodeUtils.toString(this._chordPart.keyCode) : null;
let firstPart = this._getAriaLabelForKeybinding(this._firstPart);
let chordPart = this._getAriaLabelForKeybinding(this._chordPart);
return AriaLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._os);
}
public getHTMLLabel(): IHTMLContentElement[] {
let firstPart = this._firstPart ? this._keyCodeToUILabel(this._firstPart.keyCode) : null;
let chordPart = this._chordPart ? this._keyCodeToUILabel(this._chordPart.keyCode) : null;
let firstPart = this._getUILabelForKeybinding(this._firstPart);
let chordPart = this._getUILabelForKeybinding(this._chordPart);
return UILabelProvider.toHTMLLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._os);
}
......@@ -87,21 +107,41 @@ export class USLayoutResolvedKeybinding extends ResolvedKeybinding {
return KeyCodeUtils.toString(keyCode);
}
private _getElectronAcceleratorLabelForKeybinding(keybinding: SimpleKeybinding): string {
if (!keybinding) {
return null;
}
if (keybinding.isDuplicateModifierCase()) {
return null;
}
return this._keyCodeToElectronAccelerator(keybinding.keyCode);
}
public getElectronAccelerator(): string {
if (this._chordPart !== null) {
// Electron cannot handle chords
return null;
}
let firstPart = this._firstPart ? this._keyCodeToElectronAccelerator(this._firstPart.keyCode) : null;
let firstPart = this._getElectronAcceleratorLabelForKeybinding(this._firstPart);
return ElectronAcceleratorLabelProvider.toLabel(this._firstPart, firstPart, null, null, this._os);
}
private _getUserSettingsLabelForKeybinding(keybinding: SimpleKeybinding): string {
if (!keybinding) {
return null;
}
if (keybinding.isDuplicateModifierCase()) {
return '';
}
return USER_SETTINGS.fromKeyCode(keybinding.keyCode);
}
public getUserSettingsLabel(): string {
let firstPart = this._firstPart ? USER_SETTINGS.fromKeyCode(this._firstPart.keyCode) : null;
let chordPart = this._chordPart ? USER_SETTINGS.fromKeyCode(this._chordPart.keyCode) : null;
let firstPart = this._getUserSettingsLabelForKeybinding(this._firstPart);
let chordPart = this._getUserSettingsLabelForKeybinding(this._chordPart);
let result = UserSettingsLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._os);
return result.toLowerCase();
return (result ? result.toLowerCase() : result);
}
public isWYSIWYG(): boolean {
......
......@@ -88,37 +88,77 @@ export class NativeResolvedKeybinding extends ResolvedKeybinding {
this._chordPart = chordPart;
}
private _getUILabelForScanCodeBinding(binding: ScanCodeBinding): string {
if (!binding) {
return null;
}
if (binding.isDuplicateModifierCase()) {
return '';
}
return this._mapper.getUILabelForScanCode(binding.scanCode);
}
public getLabel(): string {
let firstPart = this._firstPart ? this._mapper.getUILabelForScanCode(this._firstPart.scanCode) : null;
let chordPart = this._chordPart ? this._mapper.getUILabelForScanCode(this._chordPart.scanCode) : null;
let firstPart = this._getUILabelForScanCodeBinding(this._firstPart);
let chordPart = this._getUILabelForScanCodeBinding(this._chordPart);
return UILabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._OS);
}
private _getAriaLabelForScanCodeBinding(binding: ScanCodeBinding): string {
if (!binding) {
return null;
}
if (binding.isDuplicateModifierCase()) {
return '';
}
return this._mapper.getAriaLabelForScanCode(binding.scanCode);
}
public getAriaLabel(): string {
let firstPart = this._firstPart ? this._mapper.getAriaLabelForScanCode(this._firstPart.scanCode) : null;
let chordPart = this._chordPart ? this._mapper.getAriaLabelForScanCode(this._chordPart.scanCode) : null;
let firstPart = this._getAriaLabelForScanCodeBinding(this._firstPart);
let chordPart = this._getAriaLabelForScanCodeBinding(this._chordPart);
return AriaLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._OS);
}
public getHTMLLabel(): IHTMLContentElement[] {
let firstPart = this._firstPart ? this._mapper.getUILabelForScanCode(this._firstPart.scanCode) : null;
let chordPart = this._chordPart ? this._mapper.getUILabelForScanCode(this._chordPart.scanCode) : null;
let firstPart = this._getUILabelForScanCodeBinding(this._firstPart);
let chordPart = this._getUILabelForScanCodeBinding(this._chordPart);
return UILabelProvider.toHTMLLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._OS);
}
private _getElectronAcceleratorLabelForScanCodeBinding(binding: ScanCodeBinding): string {
if (!binding) {
return null;
}
if (binding.isDuplicateModifierCase()) {
return null;
}
return this._mapper.getElectronLabelForScanCode(binding.scanCode);
}
public getElectronAccelerator(): string {
if (this._chordPart !== null) {
// Electron cannot handle chords
return null;
}
let firstPart = this._firstPart ? this._mapper.getElectronLabelForScanCode(this._firstPart.scanCode) : null;
let firstPart = this._getElectronAcceleratorLabelForScanCodeBinding(this._firstPart);
return ElectronAcceleratorLabelProvider.toLabel(this._firstPart, firstPart, null, null, this._OS);
}
private _getUserSettingsLabelForScanCodeBinding(binding: ScanCodeBinding): string {
if (!binding) {
return null;
}
if (binding.isDuplicateModifierCase()) {
return '';
}
return this._mapper.getUserSettingsLabel(binding.scanCode);
}
public getUserSettingsLabel(): string {
let firstPart = this._firstPart ? this._mapper.getUserSettingsLabel(this._firstPart.scanCode) : null;
let chordPart = this._chordPart ? this._mapper.getUserSettingsLabel(this._chordPart.scanCode) : null;
let firstPart = this._getUserSettingsLabelForScanCodeBinding(this._firstPart);
let chordPart = this._getUserSettingsLabelForScanCodeBinding(this._chordPart);
return UserSettingsLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, this._OS);
}
......@@ -488,6 +528,17 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
this._scanCodeToLabel = [];
this._scanCodeToDispatch = [];
// Initialize `_scanCodeToLabel`
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
this._scanCodeToLabel[scanCode] = null;
}
// Initialize `_scanCodeToDispatch`
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
this._scanCodeToDispatch[scanCode] = null;
}
// Handle immutable mappings
for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
const keyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
if (keyCode !== -1) {
......@@ -530,6 +581,10 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
mappings[mappingsLen++] = mapping;
this._codeInfo[scanCode] = mapping;
if (scanCode === ScanCode.IntlHash) {
console.log('here i am');
}
this._scanCodeToDispatch[scanCode] = `[${ScanCodeUtils.toString(scanCode)}]`;
if (value >= CharCode.a && value <= CharCode.z) {
......@@ -537,6 +592,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
} else if (value) {
this._scanCodeToLabel[scanCode] = String.fromCharCode(value);
} else {
console.log(`_scanCodeToLabel[${ScanCodeUtils.toString(scanCode)}] => null.`);
this._scanCodeToLabel[scanCode] = null;
}
}
......
......@@ -238,6 +238,18 @@ export class ScanCodeBinding {
this.metaKey = metaKey;
this.scanCode = scanCode;
}
/**
* Does this keybinding refer to the key code of a modifier and it also has the modifier flag?
*/
public isDuplicateModifierCase(): boolean {
return (
(this.ctrlKey && (this.scanCode === ScanCode.ControlLeft || this.scanCode === ScanCode.ControlRight))
|| (this.shiftKey && (this.scanCode === ScanCode.ShiftLeft || this.scanCode === ScanCode.ShiftRight))
|| (this.altKey && (this.scanCode === ScanCode.AltLeft || this.scanCode === ScanCode.AltRight))
|| (this.metaKey && (this.scanCode === ScanCode.MetaLeft || this.scanCode === ScanCode.MetaRight))
);
}
}
(function () {
......
......@@ -92,21 +92,41 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
this._chordPart = chordPart;
}
private _getUILabelForKeybinding(keybinding: SimpleKeybinding): string {
if (!keybinding) {
return null;
}
if (keybinding.isDuplicateModifierCase()) {
return '';
}
return this._mapper.getUILabelForKeyCode(keybinding.keyCode);
}
public getLabel(): string {
let firstPart = this._firstPart ? this._mapper.getUILabelForKeyCode(this._firstPart.keyCode) : null;
let chordPart = this._chordPart ? this._mapper.getUILabelForKeyCode(this._chordPart.keyCode) : null;
let firstPart = this._getUILabelForKeybinding(this._firstPart);
let chordPart = this._getUILabelForKeybinding(this._chordPart);
return UILabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, OperatingSystem.Windows);
}
private _getAriaLabelForKeybinding(keybinding: SimpleKeybinding): string {
if (!keybinding) {
return null;
}
if (keybinding.isDuplicateModifierCase()) {
return '';
}
return this._mapper.getAriaLabelForKeyCode(keybinding.keyCode);
}
public getAriaLabel(): string {
let firstPart = this._firstPart ? this._mapper.getAriaLabelForKeyCode(this._firstPart.keyCode) : null;
let chordPart = this._chordPart ? this._mapper.getAriaLabelForKeyCode(this._chordPart.keyCode) : null;
let firstPart = this._getAriaLabelForKeybinding(this._firstPart);
let chordPart = this._getAriaLabelForKeybinding(this._chordPart);
return AriaLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, OperatingSystem.Windows);
}
public getHTMLLabel(): IHTMLContentElement[] {
let firstPart = this._firstPart ? this._mapper.getUILabelForKeyCode(this._firstPart.keyCode) : null;
let chordPart = this._chordPart ? this._mapper.getUILabelForKeyCode(this._chordPart.keyCode) : null;
let firstPart = this._getUILabelForKeybinding(this._firstPart);
let chordPart = this._getUILabelForKeybinding(this._chordPart);
return UILabelProvider.toHTMLLabel(this._firstPart, firstPart, this._chordPart, chordPart, OperatingSystem.Windows);
}
......@@ -131,21 +151,41 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
return KeyCodeUtils.toString(keyCode);
}
private _getElectronAcceleratorLabelForKeybinding(keybinding: SimpleKeybinding): string {
if (!keybinding) {
return null;
}
if (keybinding.isDuplicateModifierCase()) {
return null;
}
return this._keyCodeToElectronAccelerator(keybinding.keyCode);
}
public getElectronAccelerator(): string {
if (this._chordPart !== null) {
// Electron cannot handle chords
return null;
}
let firstPart = this._firstPart ? this._keyCodeToElectronAccelerator(this._firstPart.keyCode) : null;
let firstPart = this._getElectronAcceleratorLabelForKeybinding(this._firstPart);
return ElectronAcceleratorLabelProvider.toLabel(this._firstPart, firstPart, null, null, OperatingSystem.Windows);
}
private _getUserSettingsLabelForKeybinding(keybinding: SimpleKeybinding): string {
if (!keybinding) {
return null;
}
if (keybinding.isDuplicateModifierCase()) {
return '';
}
return USER_SETTINGS.fromKeyCode(keybinding.keyCode);
}
public getUserSettingsLabel(): string {
let firstPart = this._firstPart ? USER_SETTINGS.fromKeyCode(this._firstPart.keyCode) : null;
let chordPart = this._chordPart ? USER_SETTINGS.fromKeyCode(this._chordPart.keyCode) : null;
let firstPart = this._getUserSettingsLabelForKeybinding(this._firstPart);
let chordPart = this._getUserSettingsLabelForKeybinding(this._chordPart);
let result = UserSettingsLabelProvider.toLabel(this._firstPart, firstPart, this._chordPart, chordPart, OperatingSystem.Windows);
return result.toLowerCase();
return (result ? result.toLowerCase() : result);
}
public isWYSIWYG(): boolean {
......
......@@ -117,6 +117,34 @@ suite('keyboardMapper - MAC fallback', () => {
}]
);
});
test('resolveKeyboardEvent Modifier only Meta+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: true,
keyCode: KeyCode.Meta,
code: null
},
{
label: '',
ariaLabel: 'Command+',
HTMLLabel: [_simpleHTMLLabel(['', ''])],
electronAccelerator: null,
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: false,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: true,
dispatchParts: [null, null],
}
);
});
});
suite('keyboardMapper - LINUX fallback', () => {
......@@ -246,4 +274,32 @@ suite('keyboardMapper - LINUX fallback', () => {
}]
);
});
test('resolveKeyboardEvent Modifier only Ctrl+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: true,
shiftKey: false,
altKey: false,
metaKey: false,
keyCode: KeyCode.Ctrl,
code: null
},
{
label: 'Ctrl+',
ariaLabel: 'Control+',
HTMLLabel: [_simpleHTMLLabel(['Ctrl', ''])],
electronAccelerator: null,
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: true,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: false,
dispatchParts: [null, null],
}
);
});
});
......@@ -415,6 +415,62 @@ suite('keyboardMapper - MAC de_ch', () => {
}]
);
});
test('resolveKeyboardEvent Modifier only MetaLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: true,
keyCode: -1,
code: 'MetaLeft'
},
{
label: '',
ariaLabel: 'Command+',
HTMLLabel: [_simpleHTMLLabel(['', ''])],
electronAccelerator: null,
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: false,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: true,
dispatchParts: [null, null],
}
);
});
test('resolveKeyboardEvent Modifier only MetaRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: true,
keyCode: -1,
code: 'MetaRight'
},
{
label: '',
ariaLabel: 'Command+',
HTMLLabel: [_simpleHTMLLabel(['', ''])],
electronAccelerator: null,
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: false,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: true,
dispatchParts: [null, null],
}
);
});
});
suite('keyboardMapper - MAC en_us', () => {
......@@ -432,6 +488,10 @@ suite('keyboardMapper - MAC en_us', () => {
assertMapping(WRITE_FILE_IF_DIFFERENT, mapper, 'mac_en_us.txt', done);
});
function _simpleHTMLLabel(pieces: string[]): IHTMLContentElement {
return simpleHTMLLabel(pieces, OperatingSystem.Macintosh);
}
function _chordHTMLLabel(firstPart: string[], chordPart: string[]): IHTMLContentElement {
return chordHTMLLabel(firstPart, chordPart, OperatingSystem.Macintosh);
}
......@@ -457,6 +517,62 @@ suite('keyboardMapper - MAC en_us', () => {
}]
);
});
test('resolveKeyboardEvent Modifier only MetaLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: true,
keyCode: -1,
code: 'MetaLeft'
},
{
label: '',
ariaLabel: 'Command+',
HTMLLabel: [_simpleHTMLLabel(['', ''])],
electronAccelerator: null,
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: false,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: true,
dispatchParts: [null, null],
}
);
});
test('resolveKeyboardEvent Modifier only MetaRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: true,
keyCode: -1,
code: 'MetaRight'
},
{
label: '',
ariaLabel: 'Command+',
HTMLLabel: [_simpleHTMLLabel(['', ''])],
electronAccelerator: null,
userSettingsLabel: 'cmd+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: false,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: true,
dispatchParts: [null, null],
}
);
});
});
suite('keyboardMapper - LINUX de_ch', () => {
......@@ -845,6 +961,62 @@ suite('keyboardMapper - LINUX de_ch', () => {
}]
);
});
test('resolveKeyboardEvent Modifier only ControlLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: true,
shiftKey: false,
altKey: false,
metaKey: false,
keyCode: -1,
code: 'ControlLeft'
},
{
label: 'Ctrl+',
ariaLabel: 'Control+',
HTMLLabel: [_simpleHTMLLabel(['Ctrl', ''])],
electronAccelerator: null,
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: true,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: false,
dispatchParts: [null, null],
}
);
});
test('resolveKeyboardEvent Modifier only ControlRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: true,
shiftKey: false,
altKey: false,
metaKey: false,
keyCode: -1,
code: 'ControlRight'
},
{
label: 'Ctrl+',
ariaLabel: 'Control+',
HTMLLabel: [_simpleHTMLLabel(['Ctrl', ''])],
electronAccelerator: null,
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: true,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: false,
dispatchParts: [null, null],
}
);
});
});
suite('keyboardMapper - LINUX en_us', () => {
......@@ -1254,6 +1426,62 @@ suite('keyboardMapper - LINUX en_us', () => {
}]
);
});
test('resolveKeyboardEvent Modifier only ControlLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: true,
shiftKey: false,
altKey: false,
metaKey: false,
keyCode: -1,
code: 'ControlLeft'
},
{
label: 'Ctrl+',
ariaLabel: 'Control+',
HTMLLabel: [_simpleHTMLLabel(['Ctrl', ''])],
electronAccelerator: null,
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: true,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: false,
dispatchParts: [null, null],
}
);
});
test('resolveKeyboardEvent Modifier only ControlRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: true,
shiftKey: false,
altKey: false,
metaKey: false,
keyCode: -1,
code: 'ControlRight'
},
{
label: 'Ctrl+',
ariaLabel: 'Control+',
HTMLLabel: [_simpleHTMLLabel(['Ctrl', ''])],
electronAccelerator: null,
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: true,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: false,
dispatchParts: [null, null],
}
);
});
});
function _assertKeybindingTranslation(mapper: MacLinuxKeyboardMapper, OS: OperatingSystem, kb: number, _expected: string | string[]): void {
......
......@@ -371,6 +371,34 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
}]
);
});
test('resolveKeyboardEvent Modifier only Ctrl+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: true,
shiftKey: false,
altKey: false,
metaKey: false,
keyCode: KeyCode.Ctrl,
code: null
},
{
label: 'Ctrl+',
ariaLabel: 'Control+',
HTMLLabel: [_simpleHTMLLabel(['Ctrl', ''])],
electronAccelerator: null,
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: true,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: false,
dispatchParts: [null, null],
}
);
});
});
suite('keyboardMapper - WINDOWS en_us', () => {
......@@ -452,4 +480,32 @@ suite('keyboardMapper - WINDOWS en_us', () => {
}]
);
});
test('resolveKeyboardEvent Modifier only Ctrl+', () => {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: true,
shiftKey: false,
altKey: false,
metaKey: false,
keyCode: KeyCode.Ctrl,
code: null
},
{
label: 'Ctrl+',
ariaLabel: 'Control+',
HTMLLabel: [_simpleHTMLLabel(['Ctrl', ''])],
electronAccelerator: null,
userSettingsLabel: 'ctrl+',
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: true,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: false,
dispatchParts: [null, null],
}
);
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册