Skip to content

Commit d756a92

Browse files
committed
Override MouseArea interaction only when contents are idle
1 parent bcdfbf4 commit d756a92

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

widget/src/mouse_area.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a, Message, Theme, Renderer> MouseArea<'a, Message, Theme, Renderer> {
101101
self
102102
}
103103

104-
/// The version of the cursor to use when hovering.
104+
/// The [`mouse::Interaction`] to use when hovering the area.
105105
#[must_use]
106106
pub fn mouse_interaction(
107107
mut self,
@@ -226,21 +226,22 @@ where
226226
viewport: &Rectangle,
227227
renderer: &Renderer,
228228
) -> mouse::Interaction {
229-
if !cursor.is_over(layout.bounds()) {
230-
return mouse::Interaction::default();
231-
}
232-
233-
if let Some(interaction) = self.interaction {
234-
return interaction;
235-
}
236-
237-
self.content.as_widget().mouse_interaction(
229+
let content_interaction = self.content.as_widget().mouse_interaction(
238230
&tree.children[0],
239231
layout,
240232
cursor,
241233
viewport,
242234
renderer,
243-
)
235+
);
236+
237+
match (self.interaction, content_interaction) {
238+
(Some(interaction), mouse::Interaction::Idle)
239+
if cursor.is_over(layout.bounds()) =>
240+
{
241+
interaction
242+
}
243+
_ => content_interaction,
244+
}
244245
}
245246

246247
fn draw(

0 commit comments

Comments
 (0)