settings_ui: Ensure context menu is properly populated (#34213)
This change fixes a small issue where the right-click context menu would not be populdated on the first right click in the keymap editor and the selection of the corresponding entry would be slightly delayed. Release Notes: - N/A
This commit is contained in:
parent
d7fd9245cd
commit
1583dd2d6f
1 changed files with 13 additions and 20 deletions
|
@ -814,24 +814,12 @@ impl Render for KeymapEditor {
|
||||||
});
|
});
|
||||||
|
|
||||||
right_click_menu(("keymap-table-row-menu", row_index))
|
right_click_menu(("keymap-table-row-menu", row_index))
|
||||||
.trigger({
|
.trigger(move |_, _, _| row)
|
||||||
let this = cx.weak_entity();
|
|
||||||
move |is_menu_open: bool, _window, cx| {
|
|
||||||
if is_menu_open {
|
|
||||||
this.update(cx, |this, cx| {
|
|
||||||
if this.selected_index != Some(row_index) {
|
|
||||||
this.selected_index = Some(row_index);
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
row
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.menu({
|
.menu({
|
||||||
let this = cx.weak_entity();
|
let this = cx.weak_entity();
|
||||||
move |window, cx| build_keybind_context_menu(&this, window, cx)
|
move |window, cx| {
|
||||||
|
build_keybind_context_menu(&this, row_index, window, cx)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.into_any_element()
|
.into_any_element()
|
||||||
}),
|
}),
|
||||||
|
@ -1503,14 +1491,19 @@ impl Render for KeystrokeInput {
|
||||||
|
|
||||||
fn build_keybind_context_menu(
|
fn build_keybind_context_menu(
|
||||||
this: &WeakEntity<KeymapEditor>,
|
this: &WeakEntity<KeymapEditor>,
|
||||||
|
item_idx: usize,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Entity<ContextMenu> {
|
) -> Entity<ContextMenu> {
|
||||||
ContextMenu::build(window, cx, |menu, _window, cx| {
|
ContextMenu::build(window, cx, |menu, _window, cx| {
|
||||||
let Some(this) = this.upgrade() else {
|
let selected_binding = this
|
||||||
return menu;
|
.update(cx, |this, _cx| {
|
||||||
};
|
this.selected_index = Some(item_idx);
|
||||||
let selected_binding = this.read_with(cx, |this, _cx| this.selected_binding().cloned());
|
this.selected_binding().cloned()
|
||||||
|
})
|
||||||
|
.ok()
|
||||||
|
.flatten();
|
||||||
|
|
||||||
let Some(selected_binding) = selected_binding else {
|
let Some(selected_binding) = selected_binding else {
|
||||||
return menu;
|
return menu;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue