在用gojs做一个点击小方块可以移动然后可以连接的东西,这些都已经实现了,但是如何获取我小方块的元素呢?这些小方块是存在于canvas里面的。不知道有什么获取的方法。。。有木有人帮忙看一下滴
主要的小方块的代码如下,这是gojs里设置小方块的默认样式
//这段是默认矩形的代码
myDiagram.nodeTemplateMap.add("", // the default category 默认分类
$(go.Node, "Spot", nodeStyle(),
// the main object is a Panel that surrounds a TextBlock with a rectangular Shape
$(go.Panel, "Auto",
$(go.Shape, "Rectangle",
{ fill: "#00A9C9", stroke: null }),
// new go.Binding("figure", "figure")),
$(go.TextBlock,
{
font: "bold 11pt Helvetica, Arial, sans-serif",
stroke: lightText,
margin: 8,
maxSize: new go.Size(800, NaN),
wrap: go.TextBlock.WrapFit,
editable: true
},
new go.Binding("text").makeTwoWay())
),
// four named ports, one on each side:
//下面是小方块之间的连接
makePort("T", go.Spot.Top, true, true),
makePort("L", go.Spot.Left, true, true),
makePort("R", go.Spot.Right, true, true),
makePort("B", go.Spot.Bottom, true, true)
));
html代码
<body onload="init()">
<div id="sample">
<h3>GoJS Flowchart</h3>
<div style="width:100%; white-space:nowrap;">
<span style="display: inline-block; vertical-align: top; padding: 5px; width:100px">
<div id="myPaletteDiv" style="border: solid 1px gray; height: 720px"></div>
</span>
<span style="display: inline-block; vertical-align: top; padding: 5px; width:80%;position:relative;">
<div id="myDiagramDiv" style="border: solid 1px gray; height: 720px"></div>
</span>
</div>
</body>
就是下面已经移动到了中间的小方块,请教大家如何获取他,我想点击他的时候出现弹窗。