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(