dojox绘制矩形连接方法

dojox drawing rectangle connect method

本文关键字:连接 方法 绘制 dojox      更新时间:2023-09-26

Dojox绘图api有矩形作为模板,我们可以在绘图画布上使用。文档中提到了一个名为connect的函数。我该如何使用它?connect(o, e, s, m, once)

以下内容在未压缩的dojo代码中可用。

// TODO: connect to a Shape event from outside class
connect: function(o, e, s, m, /* Boolean*/once){
// summary:
//      Convenience method for quick connects
//      See comments below for possiblities
//      functions can be strings
// once:
//      If true, the connection happens only
//      once then disconnects. Five args are required
//      for this functionality.

目前尚不清楚为什么以及如何使用此功能。有人能帮我了解一下这个函数的用法和功能吗。

前四个方法被传递给dojo.connect

https://dojotoolkit.org/reference-guide/1.6/dojo/connect.html#usage

  • o-对象
  • 电子事件
  • s-范围或上下文
  • m法

将此对象的事件连接到具有作用域的方法。

dojo.connect(domNode, 'click', { test: 1}, function() {
  var t = this test;
  // is one because 'this' is the scope we pass the connect method. 
});

每次点击特定的dom节点时,都会执行该功能。

最后一个参数once是便利方法特有的。如果为true,则该函数将只执行一次。执行后,处理程序将断开连接。