From 452cabe274c1de0665f598f3aae0950bcb6c490e Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Sun, 7 Apr 2024 21:34:44 -0700 Subject: [PATCH] Clarify code related to the cursor when pressing delete --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0f9687a..0e05317 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -257,7 +257,9 @@ fn keyboard( KeyCode::Delete => { if pos < text_input.0.len() { text_input.0 = remove_char_at(&text_input.0, cursor_pos.0); - cursor_pos.0 -= 0; + + // Ensure that the cursor isn't reset + cursor_pos.set_changed(); cursor_timer.should_reset = true; continue; @@ -315,6 +317,8 @@ fn update_value( continue; }; + // Reset the cursor to the end of the input when the value is changed by + // a user manipulating the value component. if text_input.is_changed() && !cursor_pos.is_changed() { cursor_pos.0 = text_input.0.chars().count(); }