[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.
This commit is contained in:
parent
11739283f8
commit
f7d6b6be96
1 changed files with 22 additions and 14 deletions
|
|
@ -237,6 +237,7 @@ where
|
|||
clip: bool,
|
||||
drag_lift: f32,
|
||||
animation_duration: Duration,
|
||||
mouse_interaction: mouse::Interaction,
|
||||
on_reorder: Box<dyn Fn(Vec<Key>) -> Message + 'a>,
|
||||
keys: Vec<Key>,
|
||||
locked: Vec<bool>,
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue