From 2fb69afde6adfc793adb268f35723a8378be6392 Mon Sep 17 00:00:00 2001 From: Johannes Witt Date: Sun, 1 Aug 2021 03:19:55 +0200 Subject: Add GraphEdit.is_node_hover_valid(...) method This is a virtual method that can be used to add additional error condition checks while the connection is still being dragged. If true is returned, the connection is valid. If false is returned, the connection is invalid and thus not possible (ie. it will not snap). The virtual method is exposed with an underscore to scripts. --- doc/classes/GraphEdit.xml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'doc') diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index 965dbe7449..33145dccd0 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -55,6 +55,29 @@ [/codeblock] + + + + + + + + This virtual method can be used to insert additional error detection while the user is dragging a connection over a valid port. + Return [code]true[/code] if the connection is indeed valid or return [code]false[/code] if the connection is impossible. If the connection is impossible, no snapping to the port and thus no connection request to that port will happen. + In this example a connection to same node is suppressed: + [codeblocks] + [gdscript] + func _is_node_hover_valid(from, from_slot, to, to_slot): + return from != to + [/gdscript] + [csharp] + public override bool _IsNodeHoverValid(String from, int fromSlot, String to, int toSlot) { + return from != to; + } + [/csharp] + [/codeblocks] + + -- cgit v1.2.3