diff options
author | mechPenSketch <pikadon92@gmail.com> | 2021-08-23 20:04:18 +0800 |
---|---|---|
committer | mechPenSketch <pikadon92@gmail.com> | 2021-12-12 15:20:40 +0800 |
commit | 0449b30bbc163d80a8593ce77c4f4f53ae18c6e4 (patch) | |
tree | 7a63c9f3ff55e69b5103e579f8700885733f1af6 /doc/classes | |
parent | 61d681cfb9a89f5c32a6c85e8f1cf53360c6eddb (diff) |
Expose connection hot zones in GraphNode
Diffstat (limited to 'doc/classes')
-rw-r--r-- | doc/classes/GraphEdit.xml | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index c870026d58..2e35383964 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -18,6 +18,43 @@ Virtual method which can be overridden to customize how connections are drawn. </description> </method> + <method name="_is_in_input_hotzone" qualifiers="virtual"> + <return type="bool" /> + <argument index="0" name="graph_node" type="Object" /> + <argument index="1" name="slot_index" type="int" /> + <argument index="2" name="mouse_position" type="Vector2" /> + <description> + Returns whether the [code]mouse_position[/code] is in the input hot zone. + By default, a hot zone is a [Rect2] positioned such that its center is at [code]graph_node[/code].[method GraphNode.get_connection_input_position]([code]slot_index[/code]) (For output's case, call [method GraphNode.get_connection_output_position] instead). The hot zone's width is twice the Theme Property [code]port_grab_distance_horizontal[/code], and its height is twice the [code]port_grab_distance_vertical[/code]. + Below is a sample code to help get started: + [codeblock] + func _is_in_input_hotzone(graph_node, slot_index, mouse_position): + var slot_size : Vector2 = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical")) + var slot_pos : Vector2 = graph_node.get_position() + graph_node.get_connection_input_position(slot_index) - slot_size / 2 + var rect = Rect2(slot_pos, slot_size) + + return rect.has_point(mouse_position) + [/codeblock] + </description> + </method> + <method name="_is_in_output_hotzone" qualifiers="virtual"> + <return type="bool" /> + <argument index="0" name="graph_node" type="Object" /> + <argument index="1" name="slot_index" type="int" /> + <argument index="2" name="mouse_position" type="Vector2" /> + <description> + Returns whether the [code]mouse_position[/code] is in the output hot zone. For more information on hot zones, see [method _is_in_input_hotzone]. + Below is a sample code to help get started: + [codeblock] + func _is_in_output_hotzone(graph_node, slot_index, mouse_position): + var slot_size : Vector2 = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical")) + var slot_pos : Vector2 = graph_node.get_position() + graph_node.get_connection_output_position(slot_index) - slot_size / 2 + var rect = Rect2(slot_pos, slot_size) + + return rect.has_point(mouse_position) + [/codeblock] + </description> + </method> <method name="add_valid_connection_type"> <return type="void" /> <argument index="0" name="from_type" type="int" /> |