mirror of
https://github.com/eliasstepanik/egui_node_graph.git
synced 2026-01-09 21:08:28 +00:00
Allow inserting responses in draw_graph_editor
This allows a user to trigger an event externally as if it was created by UI. For example, to remove a node one just needs to insert a NodeRespone::DeleteNodeUi. Without this feature one needs to remove the node from the graph *and* adjust the internal state of GraphEditorState.
This commit is contained in:
parent
943cd4b94c
commit
7cf8181c36
@ -111,6 +111,7 @@ where
|
||||
ui: &mut Ui,
|
||||
all_kinds: impl NodeTemplateIter<Item = NodeTemplate>,
|
||||
user_state: &mut UserState,
|
||||
prepend_responses: Vec<NodeResponse<UserResponse, NodeData>>,
|
||||
) -> GraphResponse<UserResponse, NodeData> {
|
||||
// This causes the graph editor to use as much free space as it can.
|
||||
// (so for windows it will use up to the resizeably set limit
|
||||
@ -130,7 +131,7 @@ where
|
||||
|
||||
// The responses returned from node drawing have side effects that are best
|
||||
// executed at the end of this function.
|
||||
let mut delayed_responses: Vec<NodeResponse<UserResponse, NodeData>> = vec![];
|
||||
let mut delayed_responses: Vec<NodeResponse<UserResponse, NodeData>> = prepend_responses;
|
||||
|
||||
// Used to detect when the background was clicked
|
||||
let mut click_on_background = false;
|
||||
|
||||
@ -417,8 +417,12 @@ impl eframe::App for NodeGraphExample {
|
||||
});
|
||||
let graph_response = egui::CentralPanel::default()
|
||||
.show(ctx, |ui| {
|
||||
self.state
|
||||
.draw_graph_editor(ui, AllMyNodeTemplates, &mut self.user_state)
|
||||
self.state.draw_graph_editor(
|
||||
ui,
|
||||
AllMyNodeTemplates,
|
||||
&mut self.user_state,
|
||||
Vec::default(),
|
||||
)
|
||||
})
|
||||
.inner;
|
||||
for node_response in graph_response.node_responses {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user