mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 12:33:35 +01:00
Assign accelerator keys to dialog buttons (fixes #1693)
This commit is contained in:
@@ -9,6 +9,7 @@ import {IWindowService} from 'vs/workbench/services/window/electron-browser/wind
|
||||
import nls = require('vs/nls');
|
||||
import {WorkbenchMessageService} from 'vs/workbench/services/message/browser/messageService';
|
||||
import {IConfirmation} from 'vs/platform/message/common/message';
|
||||
import {isWindows} from 'vs/base/common/platform';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
@@ -28,7 +29,7 @@ export class MessageService extends WorkbenchMessageService {
|
||||
|
||||
public confirm(confirmation: IConfirmation): boolean {
|
||||
if (!confirmation.primaryButton) {
|
||||
confirmation.primaryButton = nls.localize('yesButton', "Yes");
|
||||
confirmation.primaryButton = nls.localize('yesButton', "&&Yes");
|
||||
}
|
||||
|
||||
if (!confirmation.secondaryButton) {
|
||||
@@ -39,8 +40,8 @@ export class MessageService extends WorkbenchMessageService {
|
||||
title: confirmation.title || this.contextService.getConfiguration().env.appName,
|
||||
message: confirmation.message,
|
||||
buttons: [
|
||||
confirmation.primaryButton,
|
||||
confirmation.secondaryButton
|
||||
this.mnemonicLabel(confirmation.primaryButton),
|
||||
this.mnemonicLabel(confirmation.secondaryButton)
|
||||
],
|
||||
noLink: true,
|
||||
cancelId: 1
|
||||
@@ -54,4 +55,12 @@ export class MessageService extends WorkbenchMessageService {
|
||||
|
||||
return result === 0 ? true : false;
|
||||
}
|
||||
|
||||
private mnemonicLabel(label: string): string {
|
||||
if (!isWindows) {
|
||||
return label.replace(/&&/g, ''); // no mnemonic support on mac/linux in buttons yet
|
||||
}
|
||||
|
||||
return label.replace(/&&/g, '&');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user