mirror of
https://github.com/eliasstepanik/egui_node_graph.git
synced 2026-01-10 05:18:27 +00:00
Node can decide whether it can be deleted
This commit is contained in:
parent
070ff85bd3
commit
d2350d494a
@ -771,9 +771,16 @@ where
|
||||
// --- Interaction ---
|
||||
|
||||
// Titlebar buttons
|
||||
if Self::close_button(ui, outer_rect).clicked() {
|
||||
responses.push(NodeResponse::DeleteNodeUi(self.node_id));
|
||||
};
|
||||
let can_delete = self.graph.nodes[self.node_id].user_data.can_delete(
|
||||
self.node_id,
|
||||
self.graph,
|
||||
user_state,
|
||||
);
|
||||
if can_delete {
|
||||
if Self::close_button(ui, outer_rect).clicked() {
|
||||
responses.push(NodeResponse::DeleteNodeUi(self.node_id));
|
||||
};
|
||||
}
|
||||
|
||||
let window_response = ui.interact(
|
||||
outer_rect,
|
||||
|
||||
@ -102,6 +102,15 @@ where
|
||||
) -> Option<egui::Color32> {
|
||||
None
|
||||
}
|
||||
|
||||
fn can_delete(
|
||||
&self,
|
||||
_node_id: NodeId,
|
||||
_graph: &Graph<Self, Self::DataType, Self::ValueType>,
|
||||
_user_state: &mut Self::UserState,
|
||||
) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/// This trait can be implemented by any user type. The trait tells the library
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user