首页 \ 问答 \ Paper.js中的事件处理程序(Event handlers in Paper.js)

Paper.js中的事件处理程序(Event handlers in Paper.js)

我是Paper.js的新手,在阅读教程的同时,我对事件系统感到惊奇。 多数民众赞成在教程中描述的事件:

var path;
function onMouseDown(event) {
    // Create a path:
    path = new Path();
    path.strokeColor = 'black';
    // Add the mouse down position:
    path.add(event.point);
}

function onMouseUp(event) {
    // Add the mouse up position:
    path.add(event.point);
}

所以,它在全局命名空间中的正义功能......
最终我对此有几个问题,并且我没有在网上找到任何关于此的问题:
如何将事件处理程序绑定到特定的画布?
- 如何将事件处理程序绑定到特定的“对象”(光栅图像,矩形等)?
- 如何绑定多个事件处理程序?


I am new to Paper.js, and I was wondered by the event system, while reading tutorial. Thats how event hanling described in tutorial:

var path;
function onMouseDown(event) {
    // Create a path:
    path = new Path();
    path.strokeColor = 'black';
    // Add the mouse down position:
    path.add(event.point);
}

function onMouseUp(event) {
    // Add the mouse up position:
    path.add(event.point);
}

So, its just functions in global namespace...
Eventually I have a few questions about it, and I didnt found anything on the internet on this:
- How to bind event handler to particular canvas?
- How to bind event handler to particular "object" (raster image, rectangle, etc)?
- How to bind multiple event handlers to something?


原文:https://stackoverflow.com/questions/19788760
更新时间:2024-01-15 22:01

最满意答案

这是Java的设计决定 。 你永远不会得到它,所以不要太担心它。 虽然MI可能会帮助你制作Mixins,但这是你唯一的良好MI。


It was a design decision of Java. You'll never get it, so don't worry too much about it. Although MI might help you make Mixins, that's the only good MI will ever do you.

相关问答

更多
  • 这是Java的设计决定 。 你永远不会得到它,所以不要太担心它。 虽然MI可能会帮助你制作Mixins,但这是你唯一的良好MI。 It was a design decision of Java. You'll never get it, so don't worry too much about it. Although MI might help you make Mixins, that's the only good MI will ever do you.
  • 只是为了澄清我的评论。 就像达思Eru说,你创建了两个接口和两个默认实现。 当你有一个需要这两个行为的bean时,你可以实现这两个接口,但是你也可以创建默认实现的变量。 这样你仍然不需要复制任何代码。 interface InfoMessAware { String getMessage(); } interface BackPageAware { String getBackPage(); } class DefaultInfoM ...
  • 因为接口只指定类正在做什么,而不是如何做。 多重继承的问题是两个类可能会定义不同的做同样事物的方式,而子类不能选择要选择哪一个。 Because interfaces specify only what the class is doing, not how it is doing it. The problem with multiple inheritance is that two classes may define different ways of doing the same thing, a ...
  • 假设你的域名有两种:卡车和厨房 卡车有一个driveTo()方法和Kitchens一个cook()方法。 现在假设保利决定从送货车后面出售比萨饼。 他想要一个他可以驱动to()和cook()的东西。 在C ++中,他将使用多个继承来执行此操作。 在被认为是太危险的Java中,您可以从主类继承,但是您可以从接口“继承”行为,这些行为是针对所有意图和目的而没有字段或方法实现的抽象类。 所以在Java中,我们倾向于使用代理实现多重继承: 保利将一辆卡车分类,并在一个称为厨房的成员变量中的车上加了一个厨房。 他通过 ...
  • 简短的答案是:因为语言设计师决定不去。 基本上,似乎.NET和Java设计人员都不允许多重继承,因为他们认为添加MI在语言上增加了太多的复杂性 ,同时提供了太少的好处 。 为了更有趣和深入的阅读,有一些文章可以在网络上访问一些语言设计师。 例如,对于.NET,Chris Brumme(在CLR的MS工作)已经解释了为什么他们决定不: 实际上,不同的语言对MI的工作有着不同的期望。 例如,冲突如何解决以及重复基础是合并还是多余的。 在CLR实施MI之前,我们必须对所有语言进行调查,找出常见的概念,并决定如何用 ...
  • 您可以为动物类(生物学意义上的类)创建界面,例如用于马的public interface Equidae和鸟的public interface Avialae (我不是生物学家,因此术语可能是错误的)。 那么你仍然可以创建一个 public class Bird implements Avialae { } 和 public class Horse implements Equidae {} 并且 public class Pegasus implements Avialae, Equidae {} ...
  • Java(与C ++不同)不允许多 态 继承 状态 ,因此不会遭受钻石问题的困扰 。 它允许通过接口多种类型的继承(一个类可以实现多个接口)。 从Java 8开始,通过接口中的default方法还有多个行为继承。 Java (unlike C++) does not allow multiple inheritance of state and, therefore, does not suffer from a diamond problem. It allows multiple inheritance ...
  • 否。接口定义了实现应该如何与外部世界通信,而不是定义任何行为。 您当然可以实现多个接口,但这并不意味着您有多个继承,只是实现接口的类可以显示为不同的东西。 No. An interface defines how an implementation should communicate with the outside world you do not define any behavior. You can of course implement multiple interfaces but that ...
  • 但是,如何同时从Object和任何其他类继承? 这不是一个多重继承。 不,这不是发生的事情。 并非所有类都直接从Object类扩展。 但只有顶级继承层次结构中的类从Object类扩展( 隐式 )。 层次结构中较低的其余类从Object类扩展到超类 。 而且,这就是我们所说的多级继承 。 因此,请考虑以下层次结构: - class A { } class B extends A { } 在上面的例子中, class A class A extends Object相当于class A extends Ob ...
  • 多个实现继承和多个接口继承不是相同的野兽。 但是,如果要添加多个实现继承,则会使GC和其他语言实现复杂化。 Multiple implementation inheritance and multiple interface inheritance are not the same beasts. However, it would significantly complicate the GC and other language implementation if they were to add mu ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)