From f7d6b6be963eccba3a3011c30e5424881973d2ed Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 5 May 2026 11:29:13 -0500 Subject: [PATCH] [fix]: tweak mouse interaction logic in draggable::flex_row We need to show the content interaction first, unless dragging, and by default uses no interaction so developer can choose which to really show. --- src/ui/widgets/draggable/flex_row.rs | 36 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/ui/widgets/draggable/flex_row.rs b/src/ui/widgets/draggable/flex_row.rs index b3d6a4a..ad03643 100644 --- a/src/ui/widgets/draggable/flex_row.rs +++ b/src/ui/widgets/draggable/flex_row.rs @@ -237,6 +237,7 @@ where clip: bool, drag_lift: f32, animation_duration: Duration, + mouse_interaction: mouse::Interaction, on_reorder: Box) -> Message + 'a>, keys: Vec, locked: Vec, @@ -257,6 +258,7 @@ where clip: false, drag_lift: DEFAULT_DRAG_LIFT, animation_duration: DEFAULT_ANIMATION_DURATION, + mouse_interaction: mouse::Interaction::None, on_reorder: Box::new(on_reorder), keys: Vec::new(), locked: Vec::new(), @@ -300,6 +302,11 @@ where self } + pub fn mouse(mut self, mouse_interaction: mouse::Interaction) -> Self { + self.mouse_interaction = mouse_interaction; + self + } + /// Leave disabled for dragged item to visibly lift above the row. pub fn clip(mut self, clip: bool) -> Self { self.clip = clip; @@ -809,19 +816,8 @@ where return mouse::Interaction::Grabbing; } - if let Some(cursor_pos) = cursor.position() - && self - .locked - .iter() - .zip(layout.children()) - .any(|(locked, child_layout)| { - !*locked && child_layout.bounds().contains(cursor_pos) - }) - { - return mouse::Interaction::Grab; - } - - self.children + let Some(interaction) = self + .children .iter() .zip(&tree.children) .zip(layout.children()) @@ -835,7 +831,19 @@ where ) }) .max() - .unwrap_or_default() + else { + if let Some(cursor_pos) = cursor.position() + && self.locked.iter().zip(layout.children()).any( + |(locked, child_layout)| { + !*locked && child_layout.bounds().contains(cursor_pos) + }, + ) + { + return self.mouse_interaction; + } + return mouse::Interaction::None; + }; + interaction } fn draw(