dojo gfx 中形状的事件处理

发布于 2024-12-14 03:07:12 字数 395 浏览 8 评论 0原文

我正在创建一个表面并在其上绘制一些形状。现在正在执行一个

dojo.connect(iSurface.getEventSource(), "mousedown", HandleMouseDown);

并在处理程序期间尝试使目标形状可移动。

HandleMouseDown(event)
{
    foo = new dojox.gfx.Moveable(event.target);
}

然而我不断收到“this.shape.connect 不是一个函数”,我认为这是因为 event.target 是 svg 矩形而不是 gfx 形状对象。谁能帮我找到如何在事件中获取 gfx 形状对象而不是底层 svg 对象?

谢谢。

I am creating a surface and drawing some shapes onto it. Now doing a

dojo.connect(iSurface.getEventSource(), "mousedown", HandleMouseDown);

and during handler trying to make the target shape moveable.

HandleMouseDown(event)
{
    foo = new dojox.gfx.Moveable(event.target);
}

However I keep getting "this.shape.connect is not a function", I think this is due to the fact that event.target is a svg rect not a gfx shape object. Can anyone help me in finding how do I get gfx shape object in the event instead of underlying svg object?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稚气少女 2024-12-21 03:07:12

您可以提供上下文作为 dojo.connect: 的参数,

dojo.connect(iSurface.getEventSource(), 'mousedown', {shapeObj: svgShape}, HandleMouseDown);

或者如果 shapeObj 对象属于 this:

dojo.connect(iSurface.getEventSource(), 'mousedown', this, HandleMouseDown);

并在事件处理程序中包含 this.shapeObj:

function HandleMouseDown(e) {
  foo = new dojox.gfx.Moveable(this.shapeObj);
}

You can provide context as an argument to dojo.connect:

dojo.connect(iSurface.getEventSource(), 'mousedown', {shapeObj: svgShape}, HandleMouseDown);

or if shapeObj object belongs to this:

dojo.connect(iSurface.getEventSource(), 'mousedown', this, HandleMouseDown);

and have this.shapeObj in event handler:

function HandleMouseDown(e) {
  foo = new dojox.gfx.Moveable(this.shapeObj);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文