Close the client's dialogs with Escape

Only the option-pane prompts closed on Escape, because Swing installs
that binding on the option pane itself. Dialogs.closeOnEscape puts the
same window-wide binding on a dialog's root pane, routed to whatever
that dialog does when its Close or Cancel button is pressed — reverting
the live-previewing settings, or flushing the bookmark being edited.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-14 14:36:17 +00:00
parent 0f8de796ea
commit 69003ced9a
8 changed files with 59 additions and 25 deletions

View File

@@ -116,11 +116,7 @@ public final class SettingsDialog extends JDialog {
apply();
close();
});
cancel.addActionListener(e -> {
notificationsPanel.revert();
iconPackPanel.revert();
close();
});
cancel.addActionListener(e -> cancel());
right.add(ok);
right.add(cancel);
buttons.add(right, BorderLayout.EAST);
@@ -129,6 +125,7 @@ public final class SettingsDialog extends JDialog {
getContentPane().add(tabs, BorderLayout.CENTER);
getContentPane().add(buttons, BorderLayout.SOUTH);
Dialogs.closeOnEscape(this, this::cancel);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
@Override
@@ -576,6 +573,13 @@ public final class SettingsDialog extends JDialog {
if (onApply != null) onApply.run();
}
/** Leaves without applying, putting back the settings that preview themselves live. */
private void cancel() {
notificationsPanel.revert();
iconPackPanel.revert();
close();
}
private void close() {
stopMeter();
dispose();