本文介绍了JavaFX - EventDispatcher和EventFilter之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解何时在JavaFX中使用EventDispatcher。我非常清楚捕获和冒泡的所有事件机制。但我仍然对EventDispatcher的目的感到困惑。因为我可以使用过滤器和放大器完成我的大部分工作。处理程序。

I am trying to understand when to use EventDispatcher in JavaFX. I am pretty much aware of all the event mechanisms of capturing and bubbling. But I am still confused with the purpose of EventDispatcher. Because I can get most of my work done using filters & handlers.

有人可以解释一下实际目的是什么以及如何使用这个EventDispatcher?

Can someone please explain what is the actual purpose and how to use this EventDispatcher?

谢谢。

推荐答案

必须只返回 null 已消耗code>
  • 必须能够通过相同的线程进行并发修改


    • 原因是因为 EventHandler 可能会自行删除或
      添加/删除另一个 EventHandler ,而其句柄方法正在执行。这个
      将在 EventDispatcher 以某种方式迭代 EventHandler s
      时发生。

    • It must only invoke the EventHandlers registered for the current phase (ifthere are to be phases)
    • It must only invoke the EventHandlers registered for the Event's EventTypeand said EventType's supertypes
    • It must forward the Event to the tail EventDispatchChain
    • It must only return null if the Event has been consumed
    • It must be capable of concurrent modification by the same Thread
      • The reason for this is because an EventHandler may remove itself oradd/remove another EventHandler while its handle method is executing. Thiswill take place while the EventDispatcher is iterating the EventHandlersin some way.

      • 注意:我不确定这是否实际上是合同的一部分,如果您的实施不需要,可能不是

      这篇关于JavaFX - EventDispatcher和EventFilter之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 09-18 07:21