aboutsummaryrefslogtreecommitdiff
path: root/src/text.rs
diff options
context:
space:
mode:
authoralex-ds13 <145657253+alex-ds13@users.noreply.github.com>2025-12-06 13:33:32 +0000
committerPolesznyák Márk <contact@pml68.dev>2025-12-30 18:13:59 +0100
commitd23ed3bfe439131004cf8c247fb4b4600fa92aff (patch)
treea1c71d285cc9cc963f24728d3c1acdf31d35b040 /src/text.rs
parentfix(selectable): update docs with warning about selectable usage (diff)
downloadiced_selection-d23ed3bfe439131004cf8c247fb4b4600fa92aff.tar.gz
fix(selectable): prevent clash with other's custom operations
- Make the `global_selection` operation check for the new `IndependentSelection` when trying to downcast_mut. - `IndependentSelection` uses wraps a `RefCell` so it can change its inner value. Theres some helper methods to create this `IndependentSelection` from an existing value and to then get the changed value once the operation is done. This way the `Text` and `Rich` simply need to pass this `IndependentSelection` to the operation `custom` method which will make sure it wont clash with any other custom operations that could be using `&mut bool` as well.
Diffstat (limited to 'src/text.rs')
-rw-r--r--src/text.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/text.rs b/src/text.rs
index 76560ce..4b789c9 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -752,8 +752,11 @@ where
}
}
- // let mut isel = crate::operation::IndependentSelection::new(&mut self.independent_selection);
- operation.custom(None, layout.bounds(), &mut self.independent_selection);
+ let mut isel = crate::operation::IndependentSelection::new(
+ self.independent_selection,
+ );
+ operation.custom(None, layout.bounds(), &mut isel);
+ self.independent_selection = isel.get();
}
fn mouse_interaction(