Skip to content

Commit

Permalink
Fix response handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
uglyoldbob committed Aug 17, 2024
1 parent 5a291d5 commit fbeb8e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
17 changes: 7 additions & 10 deletions src/schematic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,13 +744,12 @@ impl<'a> egui::Widget for SchematicWidget<'a> {
textnum: i,
});
}
response.context_menu(|ui| {
let r = response.context_menu(|ui| {
if ui.button("Properties").clicked() {
ui.close_menu();
}
});
// TODO check this for correctness
response
r.map(|r|r.response).or(Some(response)).unwrap()
}
MouseMode::TextDrag => {
if response.clicked() {
Expand All @@ -768,13 +767,12 @@ impl<'a> egui::Widget for SchematicWidget<'a> {
};
actions.push(a);
}
response.context_menu(|ui| {
let r = response.context_menu(|ui| {
if ui.button("Properties").clicked() {
ui.close_menu();
}
});
// TODO check this for correctness
response
r.map(|r|r.response).or(Some(response)).unwrap()
}
};
pr = pr.union(response);
Expand Down Expand Up @@ -864,7 +862,7 @@ impl<'a> egui::Widget for SchematicWidget<'a> {
self.sch.schematic_log.apply(&mut self.sch.schematic, a);
}

let pr = pr.context_menu(|ui| {
let ipr = pr.context_menu(|ui| {
if ui.button("Do a thing").clicked() {
ui.close_menu();
}
Expand All @@ -881,8 +879,7 @@ impl<'a> egui::Widget for SchematicWidget<'a> {
focusable: true,
},
);
//pr.union(response)
//TODO fix this
response

pr
}
}
12 changes: 3 additions & 9 deletions src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ impl<'a> egui::Widget for SymbolDefinitionWidget<'a> {
ui.close_menu();
}
});
//TODO check this for correctness
response
}
MouseMode::TextDrag => {
Expand All @@ -375,7 +374,6 @@ impl<'a> egui::Widget for SymbolDefinitionWidget<'a> {
ui.close_menu();
}
});
//TODO check this for correctness
response
}
};
Expand Down Expand Up @@ -405,7 +403,6 @@ impl<'a> egui::Widget for SymbolDefinitionWidget<'a> {
ui.close_menu();
}
});
// TODO check this for correctness
response
}
MouseMode::TextDrag => {
Expand All @@ -414,22 +411,21 @@ impl<'a> egui::Widget for SymbolDefinitionWidget<'a> {
ui.close_menu();
}
});
//TODO check this for correctness
response
}
};
pr = pr.union(response);
}

let pr = pr.context_menu(|ui| {
let ipr = pr.context_menu(|ui| {
if ui.button("Do a thing").clicked() {
ui.close_menu();
}
if ui.button("Close the menu").clicked() {
ui.close_menu();
}
});
if let Some(pr) = pr {
if let Some(pr) = ipr {
let pos = ui.input(|i| i.pointer.interact_pos());
if let Some(pos) = pos {
let pos2 = pos - zoom_origin.to_vec2();
Expand Down Expand Up @@ -483,9 +479,7 @@ impl<'a> egui::Widget for SymbolDefinitionWidget<'a> {
}

let (_area, response) = ui.allocate_exact_size(size, sense);
//pr.union(response)
//TODO fix this
response
pr.union(response)
}
}

Expand Down

0 comments on commit fbeb8e1

Please sign in to comment.