fix: execute must trigger render update

This commit is contained in:
imgurbot12 2024-07-10 22:21:41 -07:00
parent deda448b71
commit 63057c6f7d
2 changed files with 13 additions and 12 deletions

View File

@ -215,14 +215,14 @@ fn gui_entry(mut row: Row) -> Element {
onclick: move |_| {
row.position.with_mut(|p| p.set(row.search_index, 0));
if single_click && !menu_active {
let pos = row.position.clone();
result_ctx1.borrow_mut().execute(row.entry_index, &pos);
let mut pos = row.position.clone();
result_ctx1.borrow_mut().execute(row.entry_index, &mut pos);
}
},
ondoubleclick: move |_| {
if !menu_active {
let pos = row.position.clone();
result_ctx2.borrow_mut().execute(row.entry_index, &pos);
let mut pos = row.position.clone();
result_ctx2.borrow_mut().execute(row.entry_index, &mut pos);
}
},
// content
@ -280,13 +280,13 @@ fn gui_entry(mut row: Row) -> Element {
onclick: move |_| {
row.position.with_mut(|p| p.set(row.search_index, 0));
if single_click {
let pos = row.position.clone();
ctx.borrow_mut().execute(row.entry_index, &pos);
let mut pos = row.position.clone();
ctx.borrow_mut().execute(row.entry_index, &mut pos);
}
},
ondoubleclick: move |_| {
let pos = row.position.clone();
ctx2.borrow_mut().execute(row.entry_index, &pos);
let mut pos = row.position.clone();
ctx2.borrow_mut().execute(row.entry_index, &mut pos);
},
// content
div {
@ -333,8 +333,8 @@ fn context_menu(ctx_menu: Signal<ContextMenu>, position: Signal<Position>) -> El
href: "#",
onclick: move |_| {
position.with_mut(|p| p.subpos = idx);
let pos = position.clone();
ctx.borrow_mut().execute(index, &pos);
let mut pos = position.clone();
ctx.borrow_mut().execute(index, &mut pos);
},
"{name}"
}

View File

@ -173,9 +173,10 @@ impl Context {
self.scroll(pos.with(|p| p.pos) + 3);
}
pub fn execute(&mut self, index: usize, pos: &Pos) {
//NOTE: using with_mut to trigger rendering update
pub fn execute(&mut self, index: usize, pos: &mut Pos) {
let entry = self.get_entry(index);
let (pos, subpos) = pos.with(|p| (p.pos, p.subpos));
let (pos, subpos) = pos.with_mut(|p| (p.pos, p.subpos));
log::debug!("execute-pos {pos} {subpos}");
let Some(action) = entry.actions.get(subpos) else {
return;