dialogs - add `Cmd+D` handling (fix #71430) (#236434)

pull/236446/head
Benjamin Pasero 2024-12-18 07:26:26 +01:00 committed by GitHub
parent 3e86f1e6cd
commit 20899216df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 0 deletions

View File

@ -275,6 +275,22 @@ export class Dialog extends Disposable {
return; // leave default handling
}
// Cmd+D (trigger the "no"/"do not save"-button) (macOS only)
if (isMacintosh && evt.equals(KeyMod.CtrlCmd | KeyCode.KeyD)) {
EventHelper.stop(e);
const noButton = buttonMap.find(button => button.index === 1 && button.index !== this.options.cancelId);
if (noButton) {
resolve({
button: noButton.index,
checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
});
}
return; // leave default handling
}
if (evt.equals(KeyCode.Space)) {
return; // leave default handling
}