From 0d753c1568f7081249739bf48045a9022d577ec7 Mon Sep 17 00:00:00 2001 From: Doublonmousse <115779707+Doublonmousse@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:54:48 +0100 Subject: [PATCH] fix: change logic to keep text selection on hover/pen up (#1326) * highlight nodes when the pen or mouse hovers when text is selected * do not deselect text when the pen hovers --- crates/rnote-engine/src/pens/typewriter/mod.rs | 4 ++-- crates/rnote-engine/src/pens/typewriter/penevents.rs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/rnote-engine/src/pens/typewriter/mod.rs b/crates/rnote-engine/src/pens/typewriter/mod.rs index 928bd80c80..074ff03e27 100644 --- a/crates/rnote-engine/src/pens/typewriter/mod.rs +++ b/crates/rnote-engine/src/pens/typewriter/mod.rs @@ -206,7 +206,7 @@ impl DrawableOnDoc for Typewriter { ); let adjust_text_width_node_state = match modify_state { ModifyState::AdjustTextWidth { .. } => PenState::Down, - ModifyState::Idle => { + ModifyState::Idle | ModifyState::Selecting { .. } => { if let Some(pos) = self.pos { if adjust_text_width_node_bounds.contains_local_point(&pos.into()) { PenState::Proximity @@ -238,7 +238,7 @@ impl DrawableOnDoc for Typewriter { Self::translate_node_bounds(typewriter_bounds, engine_view.camera); let translate_node_state = match modify_state { ModifyState::Translating { .. } => PenState::Down, - ModifyState::Idle => { + ModifyState::Idle | ModifyState::Selecting { .. } => { if let Some(pos) = self.pos { if translate_node_bounds.contains_local_point(&pos.into()) { PenState::Proximity diff --git a/crates/rnote-engine/src/pens/typewriter/penevents.rs b/crates/rnote-engine/src/pens/typewriter/penevents.rs index f315ce4e32..b14c529bff 100644 --- a/crates/rnote-engine/src/pens/typewriter/penevents.rs +++ b/crates/rnote-engine/src/pens/typewriter/penevents.rs @@ -445,7 +445,12 @@ impl Typewriter { pen_down, .. } => { - *modify_state = ModifyState::Idle; + if !matches!(modify_state, ModifyState::Selecting { .. }) { + // do nothing if the state is selected + // This prevents text from becoming deselected when hovering the pen + // see issue #1222 + *modify_state = ModifyState::Idle; + } *pen_down = false; EventResult {