Browse Source

Disable input ports after load from localStorage

dds
PaulStoffregen 10 years ago
parent
commit
b4c673e5cd
2 changed files with 23 additions and 8 deletions
  1. +2
    -1
      gui/red/nodes.js
  2. +21
    -7
      gui/red/ui/view.js

+ 2
- 1
gui/red/nodes.js View File

@@ -431,7 +431,8 @@ RED.nodes = (function() {
for (var w2=0;w2<wires.length;w2++) {
var parts = wires[w2].split(":");
if (parts.length == 2 && parts[0] in node_map) {
var link = {source:n,sourcePort:w1,target:node_map[parts[0]],targetPort:parts[1]};
var dst = node_map[parts[0]];
var link = {source:n,sourcePort:w1,target:dst,targetPort:parts[1]};
addLink(link);
new_links.push(link);
}

+ 21
- 7
gui/red/ui/view.js View File

@@ -1165,18 +1165,32 @@ RED.view = (function() {
var numInputs = d._def.inputs;
var inputlist = [];
for (var n=0; n < numInputs; n++) {
var link = RED.nodes.links.filter(function(l){return (l.target == d && l.targetPort == n);});
var y = (d.h/2)-((numInputs-1)/2)*13;
y = (y+13*n)-5;
text.attr("x",38);
var rect = node.append("rect");
inputlist[n] = rect;
rect.attr("class","port port_input").attr("rx",3).attr("ry",3).attr("y",y).attr("x",-5).attr("width",10).attr("height",10).attr("index",n)
.on("mousedown", (function(nn){return function(d){portMouseDown(d,1,nn);}})(n))
.on("touchstart", (function(nn){return function(d){portMouseDown(d,1,nn);}})(n))
.on("mouseup", (function(nn){return function(d){portMouseUp(d,1,nn);}})(n))
.on("touchend", (function(nn){return function(d){portMouseUp(d,1,nn);}})(n))
.on("mouseover",function(d) { var port = d3.select(this); port.classed("port_hovered",(mouse_mode!=RED.state.JOINING || mousedown_port_type != 1 ));})
.on("mouseout",function(d) { var port = d3.select(this); port.classed("port_hovered",false);})
rect.attr("class","port port_input").attr("rx",3).attr("ry",3)
.attr("y",y).attr("x",-5).attr("width",10).attr("height",10).attr("index",n);
if (link && link.length > 0) {
// this input already has a link connected, so disallow new links
rect.on("mousedown",null)
.on("touchstart", null)
.on("mouseup", null)
.on("touchend", null)
.on("mouseover", null)
.on("mouseout", null)
.classed("port_hovered",false);
} else {
// allow new link on inputs without any link connected
rect.on("mousedown", (function(nn){return function(d){portMouseDown(d,1,nn);}})(n))
.on("touchstart", (function(nn){return function(d){portMouseDown(d,1,nn);}})(n))
.on("mouseup", (function(nn){return function(d){portMouseUp(d,1,nn);}})(n))
.on("touchend", (function(nn){return function(d){portMouseUp(d,1,nn);}})(n))
.on("mouseover",function(d) { var port = d3.select(this); port.classed("port_hovered",(mouse_mode!=RED.state.JOINING || mousedown_port_type != 1 ));})
.on("mouseout",function(d) { var port = d3.select(this); port.classed("port_hovered",false);})
}
}
d.inputlist = inputlist;


Loading…
Cancel
Save