Fix hover widget not redrawing when hovered
This commit is contained in:
parent
6fc16769c4
commit
d5a886dbcb
1 changed files with 9 additions and 1 deletions
|
|
@ -534,6 +534,7 @@ where
|
||||||
top: Element<'a, Message, Theme, Renderer>,
|
top: Element<'a, Message, Theme, Renderer>,
|
||||||
is_top_focused: bool,
|
is_top_focused: bool,
|
||||||
is_top_overlay_active: bool,
|
is_top_overlay_active: bool,
|
||||||
|
is_hovered: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
|
impl<'a, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
|
||||||
|
|
@ -655,6 +656,8 @@ where
|
||||||
let (base_layout, base_tree) = children.next().unwrap();
|
let (base_layout, base_tree) = children.next().unwrap();
|
||||||
let (top_layout, top_tree) = children.next().unwrap();
|
let (top_layout, top_tree) = children.next().unwrap();
|
||||||
|
|
||||||
|
let is_hovered = cursor.is_over(layout.bounds());
|
||||||
|
|
||||||
if matches!(event, Event::Window(window::Event::RedrawRequested(_)))
|
if matches!(event, Event::Window(window::Event::RedrawRequested(_)))
|
||||||
{
|
{
|
||||||
let mut count_focused = operation::focusable::count();
|
let mut count_focused = operation::focusable::count();
|
||||||
|
|
@ -670,6 +673,10 @@ where
|
||||||
operation::Outcome::Some(count) => count.focused.is_some(),
|
operation::Outcome::Some(count) => count.focused.is_some(),
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.is_hovered = is_hovered;
|
||||||
|
} else if is_hovered != self.is_hovered {
|
||||||
|
shell.request_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches!(
|
if matches!(
|
||||||
|
|
@ -678,7 +685,7 @@ where
|
||||||
mouse::Event::CursorMoved { .. }
|
mouse::Event::CursorMoved { .. }
|
||||||
| mouse::Event::ButtonReleased(_)
|
| mouse::Event::ButtonReleased(_)
|
||||||
)
|
)
|
||||||
) || cursor.is_over(layout.bounds())
|
) || is_hovered
|
||||||
|| self.is_top_focused
|
|| self.is_top_focused
|
||||||
|| self.is_top_overlay_active
|
|| self.is_top_overlay_active
|
||||||
{
|
{
|
||||||
|
|
@ -767,6 +774,7 @@ where
|
||||||
top: top.into(),
|
top: top.into(),
|
||||||
is_top_focused: false,
|
is_top_focused: false,
|
||||||
is_top_overlay_active: false,
|
is_top_overlay_active: false,
|
||||||
|
is_hovered: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue