Desktop: Escape in a modified game asks about saving; Escape in the question leaves
The game's Escape is taken when it leaves: the question about unsaved edits, opened in the same frame, read the same key as its own Escape and closed at once, so Escape seemed to do nothing in a modified game. In the question Escape now goes on without saving (the owner's choice); Cancel stays to keep editing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ff6c966953
commit
a3541ed1d4
3 changed files with 10 additions and 3 deletions
|
|
@ -90,7 +90,7 @@ cargo run --release -p chesspenguin -- examples/classics.pgn
|
|||
| Where | Keys |
|
||||
| --- | --- |
|
||||
| Library | ↑/↓ select · Enter open · Ctrl+O add PGN · Ctrl+N new game · Ctrl+F search |
|
||||
| Game | ←/→ move · ↑ end · ↓ start (also End/Home) · Shift+↑/↓ switch variation · F flip · L engine · Shift+A game analysis · Esc leave a preview, then back to the previous game or the library |
|
||||
| Game | ←/→ move · ↑ end · ↓ start (also End/Home) · Shift+↑/↓ switch variation · F flip · L engine · Shift+A game analysis · Esc leave a preview, then back to the previous game or the library (unsaved edits: Esc again leaves without saving) |
|
||||
| Editing | Ctrl+Z / Ctrl+Y undo/redo · Ctrl+Shift+C copy PGN · Ctrl+S save as · Ctrl+W back to library |
|
||||
|
||||
## Project layout
|
||||
|
|
|
|||
|
|
@ -761,10 +761,14 @@ impl App {
|
|||
if ui.button(tr("Save as…")).clicked() {
|
||||
choice = Some(0);
|
||||
}
|
||||
if ui.button(tr("Don't save")).clicked() {
|
||||
// Escape goes on where the user was going (the owner's choice): the
|
||||
// second Escape of "Escape, Escape" leaves without saving. Cancel stays.
|
||||
if ui.button(tr("Don't save")).on_hover_text("Esc").clicked()
|
||||
|| ui.input_mut(|i| i.consume_key(egui::Modifiers::NONE, Key::Escape))
|
||||
{
|
||||
choice = Some(1);
|
||||
}
|
||||
if ui.button(tr("Cancel")).clicked() || ui.input(|i| i.key_pressed(Key::Escape)) {
|
||||
if ui.button(tr("Cancel")).clicked() {
|
||||
choice = Some(2);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1489,6 +1489,9 @@ impl GameView {
|
|||
} else if self.board.is_busy() {
|
||||
self.board.clear();
|
||||
} else if !crate::app::overlay_open(ui.ctx()) {
|
||||
// Taken: the question about unsaved edits that leaving may open in
|
||||
// this frame must not read the same key as its own Escape.
|
||||
ui.input_mut(|i| i.consume_key(Modifiers::NONE, Key::Escape));
|
||||
actions.push(if self.previous.is_some() {
|
||||
GameAction::ReturnToPrevious
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue