diff --git a/crates/viewer/re_view_graph/src/ui/draw.rs b/crates/viewer/re_view_graph/src/ui/draw.rs index bc6f30e285ea..ad58886a3761 100644 --- a/crates/viewer/re_view_graph/src/ui/draw.rs +++ b/crates/viewer/re_view_graph/src/ui/draw.rs @@ -330,6 +330,7 @@ pub fn draw_graph( layout: &Layout, query: &ViewQuery<'_>, lod: LevelOfDetail, + hover_click_item: &mut Option<(Item, Response)>, ) -> Rect { let entity_path = graph.entity(); let entity_highlights = query.highlights.entity_highlight(entity_path.hash()); @@ -363,19 +364,18 @@ pub fn draw_graph( }); }); - ctx.handle_select_hover_drag_interactions( - &response, - Item::DataResult(query.view_id, instance_path.clone()), - false, - ); - - // double click selects the entire entity + // Warning! The order is very important here. if response.double_clicked() { // Select the entire entity ctx.selection_state().set_selection(Item::DataResult( query.view_id, instance_path.entity_path.clone().into(), )); + } else if response.hovered() || response.clicked() { + *hover_click_item = Some(( + Item::DataResult(query.view_id, instance_path.clone()), + response.clone(), + )); } response diff --git a/crates/viewer/re_view_graph/src/view.rs b/crates/viewer/re_view_graph/src/view.rs index 11b08183f761..b7ecf8b0d91e 100644 --- a/crates/viewer/re_view_graph/src/view.rs +++ b/crates/viewer/re_view_graph/src/view.rs @@ -1,3 +1,4 @@ +use egui::Response; use re_log_types::EntityPath; use re_types::{ blueprint::{ @@ -191,18 +192,28 @@ Display a graph of nodes and edges. let level_of_detail = LevelOfDetail::from_scaling(ui_from_world.scaling); + let mut hover_click_item: Option<(Item, Response)> = None; + let resp = zoom_pan_area(ui, &mut ui_from_world, |ui| { let mut world_bounding_rect = egui::Rect::NOTHING; for graph in &graphs { - let graph_rect = draw_graph(ui, ctx, graph, layout, query, level_of_detail); + let graph_rect = draw_graph( + ui, + ctx, + graph, + layout, + query, + level_of_detail, + &mut hover_click_item, + ); world_bounding_rect = world_bounding_rect.union(graph_rect); } }); - // Don't set the view to hovered if something else was already hovered. - // (this can only mean that a graph node/edge was hovered) - if resp.hovered() && ctx.selection_state().hovered_items().is_empty() { + if let Some((item, response)) = hover_click_item { + ctx.handle_select_hover_drag_interactions(&response, item, false); + } else if resp.hovered() { ctx.selection_state().set_hovered(Item::View(query.view_id)); }