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 new_hovered_option = (cursor_position.y / option_height) as usize;
let mut hovered_guard = self.hovered_option.lock().unwrap(); 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)); shell.publish(on_option_hovered(new_hovered_option));
} }
} }

View file

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

View file

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

View file

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