gojs这个库里怎么获取我移动的元素,元素是用canvas做的

特马tou 2017-03-15 05:58:15
在用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>
就是下面已经移动到了中间的小方块,请教大家如何获取他,我想点击他的时候出现弹窗。
...全文
270 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzh_lazy 2020-11-09
  • 打赏
  • 举报
回复
同问+1,有大佬吗
特马tou 2017-08-09
  • 打赏
  • 举报
回复
111hjkhkj

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧