@@ -938,6 +938,69 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
938
938
} ;
939
939
responses. add ( FrontendMessage :: UpdateWirePathInProgress { wire_path : Some ( wire_path) } ) ;
940
940
}
941
+ } else if self . disconnecting . is_some ( ) {
942
+ // Disconnecting with no upstream node, create new value node.
943
+ let to_connector = network_interface. input_connector_from_click ( ipp. mouse . position , selection_network_path) ;
944
+ if let Some ( to_connector) = & to_connector {
945
+ let Some ( input_position) = network_interface. input_position ( to_connector, selection_network_path) else {
946
+ log:: error!( "Could not get input position for connector: {to_connector:?}" ) ;
947
+ return ;
948
+ } ;
949
+ self . wire_in_progress_to_connector = Some ( input_position) ;
950
+ }
951
+ // Not hovering over a node input or node output, insert the node
952
+ else {
953
+ // Disconnect if the wire was previously connected to an input
954
+ if let Some ( disconnecting) = self . disconnecting . take ( ) {
955
+ let mut position = if let Some ( to_connector) = self . wire_in_progress_to_connector { to_connector } else { point } ;
956
+ // Offset to drag from center of node
957
+ position = position - DVec2 :: new ( 24. * 3. , 24. ) ;
958
+
959
+ // Offset to account for division rounding error
960
+ if position. x < 0. {
961
+ position. x = position. x - 1. ;
962
+ }
963
+ if position. y < 0. {
964
+ position. y = position. y - 1. ;
965
+ }
966
+
967
+ let Some ( input) = network_interface. take_input ( & disconnecting, breadcrumb_network_path) else {
968
+ return ;
969
+ } ;
970
+
971
+ let drag_start = DragStart {
972
+ start_x : point. x ,
973
+ start_y : point. y ,
974
+ round_x : 0 ,
975
+ round_y : 0 ,
976
+ } ;
977
+
978
+ self . drag_start = Some ( ( drag_start, false ) ) ;
979
+ self . node_has_moved_in_drag = false ;
980
+ self . update_node_graph_hints ( responses) ;
981
+
982
+ let node_id = NodeId :: new ( ) ;
983
+ responses. add ( NodeGraphMessage :: CreateNodeFromContextMenu {
984
+ node_id : Some ( node_id) ,
985
+ node_type : "Identity" . to_string ( ) ,
986
+ xy : Some ( ( ( position. x / 24. ) as i32 , ( position. y / 24. ) as i32 ) ) ,
987
+ } ) ;
988
+
989
+ responses. add ( NodeGraphMessage :: SetInput {
990
+ input_connector : InputConnector :: node ( node_id, 0 ) ,
991
+ input,
992
+ } ) ;
993
+
994
+ responses. add ( NodeGraphMessage :: CreateWire {
995
+ output_connector : OutputConnector :: Node { node_id, output_index : 0 } ,
996
+ input_connector : disconnecting,
997
+ } ) ;
998
+ responses. add ( NodeGraphMessage :: SelectedNodesSet { nodes : vec ! [ node_id] } ) ;
999
+ // Update the frontend that the node is disconnected
1000
+ responses. add ( NodeGraphMessage :: RunDocumentGraph ) ;
1001
+ responses. add ( NodeGraphMessage :: SendGraph ) ;
1002
+ }
1003
+ }
941
1004
} else if let Some ( ( drag_start, dragged) ) = & mut self . drag_start {
942
1005
if drag_start. start_x != point. x || drag_start. start_y != point. y {
943
1006
* dragged = true ;
0 commit comments