allow select/copy on dialogs

fixes #71407
This commit is contained in:
SteVen Batten 2019-08-26 11:52:26 -07:00
parent 355be5e7d3
commit 845202c59e
4 changed files with 25 additions and 14 deletions

View file

@ -109,13 +109,6 @@ export class Dialog extends Disposable {
return; return;
} }
if (this.modal) {
this._register(domEvent(this.modal, 'mousedown')(e => {
// Used to stop focusing of modal with mouse
EventHelper.stop(e, true);
}));
}
clearNode(this.buttonsContainer); clearNode(this.buttonsContainer);
let focusedButton = 0; let focusedButton = 0;

View file

@ -14,14 +14,18 @@ import { attachDialogStyler } from 'vs/platform/theme/common/styler';
import { DisposableStore } from 'vs/base/common/lifecycle'; import { DisposableStore } from 'vs/base/common/lifecycle';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { EventHelper } from 'vs/base/browser/dom'; import { EventHelper } from 'vs/base/browser/dom';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
export class DialogService implements IDialogService { export class DialogService implements IDialogService {
_serviceBrand: any; _serviceBrand: any;
private allowableCommands = ['copy', 'cut'];
constructor( constructor(
@ILogService private readonly logService: ILogService, @ILogService private readonly logService: ILogService,
@ILayoutService private readonly layoutService: ILayoutService, @ILayoutService private readonly layoutService: ILayoutService,
@IThemeService private readonly themeService: IThemeService @IThemeService private readonly themeService: IThemeService,
@IKeybindingService private readonly keybindingService: IKeybindingService
) { } ) { }
async confirm(confirmation: IConfirmation): Promise<IConfirmationResult> { async confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
@ -50,7 +54,12 @@ export class DialogService implements IDialogService {
cancelId: 1, cancelId: 1,
type: confirmation.type, type: confirmation.type,
keyEventProcessor: (event: StandardKeyboardEvent) => { keyEventProcessor: (event: StandardKeyboardEvent) => {
EventHelper.stop(event, true); const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
if (resolved && resolved.commandId) {
if (this.allowableCommands.indexOf(resolved.commandId) === -1) {
EventHelper.stop(event, true);
}
}
}, },
checkboxChecked: confirmation.checkbox ? confirmation.checkbox.checked : undefined, checkboxChecked: confirmation.checkbox ? confirmation.checkbox.checked : undefined,
checkboxLabel: confirmation.checkbox ? confirmation.checkbox.label : undefined checkboxLabel: confirmation.checkbox ? confirmation.checkbox.label : undefined
@ -82,7 +91,12 @@ export class DialogService implements IDialogService {
cancelId: options ? options.cancelId : undefined, cancelId: options ? options.cancelId : undefined,
type: this.getDialogType(severity), type: this.getDialogType(severity),
keyEventProcessor: (event: StandardKeyboardEvent) => { keyEventProcessor: (event: StandardKeyboardEvent) => {
EventHelper.stop(event, true); const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
if (resolved && resolved.commandId) {
if (this.allowableCommands.indexOf(resolved.commandId) === -1) {
EventHelper.stop(event, true);
}
}
} }
}); });

View file

@ -18,6 +18,7 @@ import { DialogChannel } from 'vs/platform/dialogs/node/dialogIpc';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
interface IMassagedMessageBoxOptions { interface IMassagedMessageBoxOptions {
@ -45,12 +46,13 @@ export class DialogService implements IDialogService {
@ILayoutService layoutService: ILayoutService, @ILayoutService layoutService: ILayoutService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IWindowService windowService: IWindowService, @IWindowService windowService: IWindowService,
@ISharedProcessService sharedProcessService: ISharedProcessService @ISharedProcessService sharedProcessService: ISharedProcessService,
@IKeybindingService keybindingService: IKeybindingService
) { ) {
// Use HTML based dialogs // Use HTML based dialogs
if (configurationService.getValue('workbench.dialogs.customEnabled') === true) { if (configurationService.getValue('workbench.dialogs.customEnabled') === true) {
this.impl = new HTMLDialogService(logService, layoutService, themeService); this.impl = new HTMLDialogService(logService, layoutService, themeService, keybindingService);
} }
// Electron dialog service // Electron dialog service
else { else {
@ -187,4 +189,4 @@ class NativeDialogService implements IDialogService {
} }
} }
registerSingleton(IDialogService, DialogService, true); registerSingleton(IDialogService, DialogService, true);

View file

@ -348,7 +348,9 @@ export class ProgressService extends Disposable implements IProgressService {
const disposables = new DisposableStore(); const disposables = new DisposableStore();
const allowableCommands = [ const allowableCommands = [
'workbench.action.quit', 'workbench.action.quit',
'workbench.action.reloadWindow' 'workbench.action.reloadWindow',
'copy',
'cut'
]; ];
let dialog: Dialog; let dialog: Dialog;