您可以侦听在舞台上单击事件并打开组以外的用户点击的组听:
免责声明 - 这里的一些示例代码,但我没有测试它:
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
$(stage.getContent()).on('click', function (event) {
// if the group is already listening, just exit
if(group.listening){return;}
// get the current mouse position
var pos=stage.getPointerPosition();
var mouseX=parseInt(pos.x);
var mouseY=parseInt(pos.y);
// get the current group position
var left=group.x();
var right=left+group.width();
var top=group.y();
var bottom=top+group.height();
// if the click is outside the group,
// turn the groups listening on
if(!(mouseX>left && mouseX<right && mouseY>top && mouseY<bottom)){
group.listening(true);
}
});
[更新:非jQuery的备用]
可以为鼠标点击使用stage.on听而不jQuery的( 'contentClick',函数(){}):
stage.on('contentClick',function(){
var pos=stage.getPointerPosition();
var mouseX=parseInt(pos.x);
var mouseY=parseInt(pos.y);
console.log("contentclick",mouseX,mouseY);
});
我添加到我的答案,说明一个非jquery方法来监听点击容器。干杯! – markE
非常感谢!我会测试它 –
我试过了,stage.on('contentclick',...)绑定了舞台上所有内容的点击,即使是我正在谈论的那个组。例如:http://jsfiddle.net/Rfvud/。我想操纵组中的组件事件(特别是切换动作的圆圈,以及调整大小的小锚点),以便在锁定动作时阻止大小调整。 –