fix: request redraw in menus

This commit is contained in:
Hojjat 2026-08-04 13:58:23 -06:00 • committed by Ashley Wulber
parent 1ac21a9d99
commit 5fd1ca4220
4 changed files with 14 additions and 3 deletions

View file

@ -499,8 +499,10 @@ where
let new_hovered_option = (cursor_position.y / option_height) as usize;
let mut hovered_guard = self.hovered_option.lock().unwrap();
if let Some(on_option_hovered) = self.on_option_hovered {
if *hovered_guard != Some(new_hovered_option) {
if *hovered_guard != Some(new_hovered_option) {
shell.request_redraw();
if let Some(on_option_hovered) = self.on_option_hovered {
shell.publish(on_option_hovered(new_hovered_option));
}
}

View file

@ -382,6 +382,8 @@ where
if previous_hover_option.as_ref() == Some(item) {
previous_hover_option
} else {
shell.request_redraw();
if let Some(on_option_hovered) = self.on_option_hovered {
shell.publish(on_option_hovered(item.clone()));
}

View file

@ -656,6 +656,7 @@ where
Mouse(mouse::Event::CursorMoved { .. } | mouse::Event::CursorEntered)
if open && view_cursor.is_over(layout.bounds()) =>
{
shell.request_redraw();
shell.capture_event();
#[cfg(wayland_platform)]
if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) {

View file

@ -1502,7 +1502,9 @@ where
// cursor is outside
{
last_menu_state.index = None;
if last_menu_state.index.take().is_some() {
shell.request_redraw();
}
shell.capture_event();
return new_menu_root;
}
@ -1561,6 +1563,10 @@ where
// set new index
let old_index = last_menu_state.index.replace(new_index);
if old_index != Some(new_index) {
shell.request_redraw();
}
// get new active item
// * add new menu if the new item is a menu
if !item.children.is_empty() && old_index.is_none_or(|i| i != new_index) {