diff --git a/crates/re_viewer/src/ui/selection_history_ui.rs b/crates/re_viewer/src/ui/selection_history_ui.rs index c8567f90abea..9216f69074c1 100644 --- a/crates/re_viewer/src/ui/selection_history_ui.rs +++ b/crates/re_viewer/src/ui/selection_history_ui.rs @@ -42,12 +42,18 @@ impl SelectionHistoryUi { item_collection_to_string(blueprint, &previous.selection), )); + let mut return_current = false; let response = response.context_menu(|ui| { // undo: newest on top, oldest on bottom + let cur = history.current; for i in (0..history.current).rev() { self.history_item_ui(blueprint, ui, i, history); } + return_current = cur != history.current; }); + if return_current { + return history.current().map(|sel| sel.selection); + } // TODO(cmc): using the keyboard shortcut should highlight the associated // button or something (but then again it, it'd make more sense to do that @@ -86,12 +92,18 @@ impl SelectionHistoryUi { item_collection_to_string(blueprint, &next.selection), )); + let mut return_current = false; let response = response.context_menu(|ui| { // redo: oldest on top, most recent on bottom + let cur = history.current; for i in (history.current + 1)..history.stack.len() { self.history_item_ui(blueprint, ui, i, history); } + return_current = cur != history.current; }); + if return_current { + return history.current().map(|sel| sel.selection); + } // TODO(cmc): using the keyboard shortcut should highlight the associated // button or something (but then again it, it'd make more sense to do that