Skip to content

Commit

Permalink
fix: change logic to keep text selection on hover/pen up (#1326)
Browse files Browse the repository at this point in the history
* highlight nodes when the pen or mouse hovers when text is selected

* do not deselect text when the pen hovers
  • Loading branch information
Doublonmousse authored Dec 24, 2024
1 parent e553119 commit 0d753c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/rnote-engine/src/pens/typewriter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion crates/rnote-engine/src/pens/typewriter/penevents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0d753c1

Please sign in to comment.