Override MouseArea interaction only when contents are idle
This commit is contained in:
parent
bcdfbf4871
commit
d756a9210a
1 changed files with 12 additions and 11 deletions
|
|
@ -101,7 +101,7 @@ impl<'a, Message, Theme, Renderer> MouseArea<'a, Message, Theme, Renderer> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The version of the cursor to use when hovering.
|
/// The [`mouse::Interaction`] to use when hovering the area.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn mouse_interaction(
|
pub fn mouse_interaction(
|
||||||
mut self,
|
mut self,
|
||||||
|
|
@ -226,21 +226,22 @@ where
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
) -> mouse::Interaction {
|
) -> mouse::Interaction {
|
||||||
if !cursor.is_over(layout.bounds()) {
|
let content_interaction = self.content.as_widget().mouse_interaction(
|
||||||
return mouse::Interaction::default();
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(interaction) = self.interaction {
|
|
||||||
return interaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.content.as_widget().mouse_interaction(
|
|
||||||
&tree.children[0],
|
&tree.children[0],
|
||||||
layout,
|
layout,
|
||||||
cursor,
|
cursor,
|
||||||
viewport,
|
viewport,
|
||||||
renderer,
|
renderer,
|
||||||
)
|
);
|
||||||
|
|
||||||
|
match (self.interaction, content_interaction) {
|
||||||
|
(Some(interaction), mouse::Interaction::Idle)
|
||||||
|
if cursor.is_over(layout.bounds()) =>
|
||||||
|
{
|
||||||
|
interaction
|
||||||
|
}
|
||||||
|
_ => content_interaction,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(
|
fn draw(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue