diff --git a/scripts/startup/bl_operators/connect_to_output.py b/scripts/startup/bl_operators/connect_to_output.py index 823211e8688..299555911c3 100644 --- a/scripts/startup/bl_operators/connect_to_output.py +++ b/scripts/startup/bl_operators/connect_to_output.py @@ -192,6 +192,8 @@ class NODE_OT_connect_to_output(Operator, NodeEditorBase): out_i = None valid_outputs = [] for i, out in enumerate(node.outputs): + if out.select: + return i if is_visible_socket(out) and (not check_type or out.type == socket_type): valid_outputs.append(i) if valid_outputs: @@ -259,7 +261,7 @@ class NODE_OT_connect_to_output(Operator, NodeEditorBase): mlocx = event.mouse_region_x mlocy = event.mouse_region_y - select_node = bpy.ops.node.select(location=(mlocx, mlocy), extend=False) + select_node = bpy.ops.node.select(location=(mlocx, mlocy), extend=False, socket_select=True) if 'FINISHED' not in select_node: # only run if mouse click is on a node. return {'CANCELLED'} diff --git a/source/blender/makesrna/intern/rna_node_socket.cc b/source/blender/makesrna/intern/rna_node_socket.cc index f7a8ce5bb4f..620072b1704 100644 --- a/source/blender/makesrna/intern/rna_node_socket.cc +++ b/source/blender/makesrna/intern/rna_node_socket.cc @@ -370,6 +370,13 @@ static bool rna_NodeSocket_is_output_get(PointerRNA *ptr) return sock->in_out == SOCK_OUT; } +static bool rna_NodeSocket_select_get(PointerRNA *ptr) +{ + const bNodeSocket *socket = ptr->data_as(); + + return (socket->flag & SELECT) != 0; +} + static int rna_NodeSocket_link_limit_get(PointerRNA *ptr) { bNodeSocket *sock = static_cast(ptr->data); @@ -673,6 +680,11 @@ static void rna_def_node_socket(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Is Output", "True if the socket is an output, otherwise input"); + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_NodeSocket_select_get", nullptr); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Select", "True if the socket is selected"); + prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "flag", SOCK_HIDDEN); RNA_def_property_boolean_funcs(prop, nullptr, "rna_NodeSocket_hide_set");