mirror of
https://github.com/eliasstepanik/egui_node_graph.git
synced 2026-01-10 05:18:27 +00:00
Merge pull request #76 from huisedenanhai/main
Node can decide whether it can be deleted
This commit is contained in:
commit
b5af1c745c
@ -771,7 +771,13 @@ where
|
||||
// --- Interaction ---
|
||||
|
||||
// Titlebar buttons
|
||||
if Self::close_button(ui, outer_rect).clicked() {
|
||||
let can_delete = self.graph.nodes[self.node_id].user_data.can_delete(
|
||||
self.node_id,
|
||||
self.graph,
|
||||
user_state,
|
||||
);
|
||||
|
||||
if can_delete && Self::close_button(ui, outer_rect).clicked() {
|
||||
responses.push(NodeResponse::DeleteNodeUi(self.node_id));
|
||||
};
|
||||
|
||||
|
||||
@ -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