Skip to content

Commit

Permalink
Merge pull request #11 from rmja/invoke-entry-exit
Browse files Browse the repository at this point in the history
Actually invoke menu entry and exit callbacks
  • Loading branch information
eldruin authored Jun 29, 2023
2 parents 5c0c0fd + 2f8ae2b commit 71bbeee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ where
}
}
} else if cmd == "exit" && self.depth != 0 {
if let Some(cb_fn) = self.menus[self.depth].as_ref().unwrap().exit {
cb_fn(menu, &mut self.context);
}

self.menus[self.depth] = None;
self.depth -= 1;
} else {
Expand All @@ -396,6 +400,12 @@ where
ItemType::Menu(m) => {
self.depth += 1;
self.menus[self.depth] = Some(m);

if let Some(cb_fn) =
self.menus[self.depth].as_ref().unwrap().entry
{
cb_fn(menu, &mut self.context);
}
}
ItemType::_Dummy => {
unreachable!();
Expand Down

0 comments on commit 71bbeee

Please sign in to comment.