mirror of
https://github.com/eliasstepanik/egui_node_graph.git
synced 2026-01-11 13:58:28 +00:00
Fix mouse-related bugs
- The box selection should only be activated by the primary mouse - Now that egui finally supports it, make the node finder trigger be a mouse click, not a "mouse down". This prevents a weird behavior where you could drag around the node finder when clicking and dragging with the left mouse button
This commit is contained in:
parent
7b70b706b5
commit
2607f55746
@ -112,7 +112,7 @@ where
|
|||||||
|
|
||||||
// Gets filled with the node metrics as they are drawn
|
// Gets filled with the node metrics as they are drawn
|
||||||
let mut port_locations = PortLocations::new();
|
let mut port_locations = PortLocations::new();
|
||||||
let mut node_sizes = NodeRects::new();
|
let mut node_rects = NodeRects::new();
|
||||||
|
|
||||||
// The responses returned from node drawing have side effects that are best
|
// The responses returned from node drawing have side effects that are best
|
||||||
// executed at the end of this function.
|
// executed at the end of this function.
|
||||||
@ -138,7 +138,7 @@ where
|
|||||||
position: self.node_positions.get_mut(node_id).unwrap(),
|
position: self.node_positions.get_mut(node_id).unwrap(),
|
||||||
graph: &mut self.graph,
|
graph: &mut self.graph,
|
||||||
port_locations: &mut port_locations,
|
port_locations: &mut port_locations,
|
||||||
node_rects: &mut node_sizes,
|
node_rects: &mut node_rects,
|
||||||
node_id,
|
node_id,
|
||||||
ongoing_drag: self.connection_in_progress,
|
ongoing_drag: self.connection_in_progress,
|
||||||
selected: self
|
selected: self
|
||||||
@ -365,7 +365,7 @@ where
|
|||||||
Stroke::new(3.0, stroke_color),
|
Stroke::new(3.0, stroke_color),
|
||||||
);
|
);
|
||||||
|
|
||||||
self.selected_nodes = node_sizes
|
self.selected_nodes = node_rects
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|(node_id, rect)| {
|
.filter_map(|(node_id, rect)| {
|
||||||
if selection_rect.intersects(rect) {
|
if selection_rect.intersects(rect) {
|
||||||
@ -391,7 +391,7 @@ where
|
|||||||
self.connection_in_progress = None;
|
self.connection_in_progress = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if mouse.secondary_down() && cursor_in_editor && !cursor_in_finder {
|
if mouse.secondary_clicked() && cursor_in_editor && !cursor_in_finder {
|
||||||
self.node_finder = Some(NodeFinder::new_at(cursor_pos));
|
self.node_finder = Some(NodeFinder::new_at(cursor_pos));
|
||||||
}
|
}
|
||||||
if ui.ctx().input().key_pressed(Key::Escape) {
|
if ui.ctx().input().key_pressed(Key::Escape) {
|
||||||
@ -409,7 +409,7 @@ where
|
|||||||
self.node_finder = None;
|
self.node_finder = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if drag_started_on_background {
|
if drag_started_on_background && mouse.primary_down() {
|
||||||
self.ongoing_box_selection = Some(cursor_pos);
|
self.ongoing_box_selection = Some(cursor_pos);
|
||||||
}
|
}
|
||||||
if mouse.primary_released() || drag_released_on_background {
|
if mouse.primary_released() || drag_released_on_background {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user