From e548f1255def119188e58558e81bcbab9010c9a0 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Sat, 6 Jan 2024 14:55:49 -0800 Subject: [PATCH] Closing no longer repeats Closes #108 Turns out there was a property on KeyEvent this whole time... oops. --- CHANGELOG.md | 2 ++ src/window.rs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87e00af..3c93d82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `IntoDynamic`. In general, this should not cause any code breakages unless the traits were being used in generics. - `Space` now honors `ConstraintLimit::Fill` in its layout. +- When handling the Ctrl/Cmd+W shortcut to close windows, repeat keys are now + ignored. ### Changed diff --git a/src/window.rs b/src/window.rs index bf32c39..a11041d 100644 --- a/src/window.rs +++ b/src/window.rs @@ -999,7 +999,10 @@ where { match input.logical_key { Key::Character(ch) if ch == "w" && window.modifiers().primary() => { - if input.state.is_pressed() && self.behavior.close_requested(window) { + if !input.repeat + && input.state.is_pressed() + && self.behavior.close_requested(window) + { self.should_close = true; window.set_needs_redraw(); }