1. /*
  2. * Copyright (c) 2000 World Wide Web Consortium,
  3. * (Massachusetts Institute of Technology, Institut National de
  4. * Recherche en Informatique et en Automatique, Keio University). All
  5. * Rights Reserved. This program is distributed under the W3C's Software
  6. * Intellectual Property License. This program is distributed in the
  7. * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  8. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  9. * PURPOSE.
  10. * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
  11. */
  12. package org.w3c.dom.events;
  13. /**
  14. * The <code>EventTarget</code> interface is implemented by all
  15. * <code>Nodes</code> in an implementation which supports the DOM Event
  16. * Model. Therefore, this interface can be obtained by using
  17. * binding-specific casting methods on an instance of the <code>Node</code>
  18. * interface. The interface allows registration and removal of
  19. * <code>EventListeners</code> on an <code>EventTarget</code> and dispatch
  20. * of events to that <code>EventTarget</code>.
  21. * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113'>Document Object Model (DOM) Level 2 Events Specification</a>.
  22. * @since DOM Level 2
  23. */
  24. public interface EventTarget {
  25. /**
  26. * This method allows the registration of event listeners on the event
  27. * target. If an <code>EventListener</code> is added to an
  28. * <code>EventTarget</code> while it is processing an event, it will not
  29. * be triggered by the current actions but may be triggered during a
  30. * later stage of event flow, such as the bubbling phase.
  31. * <br> If multiple identical <code>EventListener</code>s are registered
  32. * on the same <code>EventTarget</code> with the same parameters the
  33. * duplicate instances are discarded. They do not cause the
  34. * <code>EventListener</code> to be called twice and since they are
  35. * discarded they do not need to be removed with the
  36. * <code>removeEventListener</code> method.
  37. * @param typeThe event type for which the user is registering
  38. * @param listenerThe <code>listener</code> parameter takes an interface
  39. * implemented by the user which contains the methods to be called
  40. * when the event occurs.
  41. * @param useCaptureIf true, <code>useCapture</code> indicates that the
  42. * user wishes to initiate capture. After initiating capture, all
  43. * events of the specified type will be dispatched to the registered
  44. * <code>EventListener</code> before being dispatched to any
  45. * <code>EventTargets</code> beneath them in the tree. Events which
  46. * are bubbling upward through the tree will not trigger an
  47. * <code>EventListener</code> designated to use capture.
  48. */
  49. public void addEventListener(String type,
  50. EventListener listener,
  51. boolean useCapture);
  52. /**
  53. * This method allows the removal of event listeners from the event
  54. * target. If an <code>EventListener</code> is removed from an
  55. * <code>EventTarget</code> while it is processing an event, it will not
  56. * be triggered by the current actions. <code>EventListener</code>s can
  57. * never be invoked after being removed.
  58. * <br>Calling <code>removeEventListener</code> with arguments which do
  59. * not identify any currently registered <code>EventListener</code> on
  60. * the <code>EventTarget</code> has no effect.
  61. * @param typeSpecifies the event type of the <code>EventListener</code>
  62. * being removed.
  63. * @param listenerThe <code>EventListener</code> parameter indicates the
  64. * <code>EventListener </code> to be removed.
  65. * @param useCaptureSpecifies whether the <code>EventListener</code>
  66. * being removed was registered as a capturing listener or not. If a
  67. * listener was registered twice, one with capture and one without,
  68. * each must be removed separately. Removal of a capturing listener
  69. * does not affect a non-capturing version of the same listener, and
  70. * vice versa.
  71. */
  72. public void removeEventListener(String type,
  73. EventListener listener,
  74. boolean useCapture);
  75. /**
  76. * This method allows the dispatch of events into the implementations
  77. * event model. Events dispatched in this manner will have the same
  78. * capturing and bubbling behavior as events dispatched directly by the
  79. * implementation. The target of the event is the
  80. * <code> EventTarget</code> on which <code>dispatchEvent</code> is
  81. * called.
  82. * @param evtSpecifies the event type, behavior, and contextual
  83. * information to be used in processing the event.
  84. * @return The return value of <code>dispatchEvent</code> indicates
  85. * whether any of the listeners which handled the event called
  86. * <code>preventDefault</code>. If <code>preventDefault</code> was
  87. * called the value is false, else the value is true.
  88. * @exception EventException
  89. * UNSPECIFIED_EVENT_TYPE_ERR: Raised if the <code>Event</code>'s type
  90. * was not specified by initializing the event before
  91. * <code>dispatchEvent</code> was called. Specification of the
  92. * <code>Event</code>'s type as <code>null</code> or an empty string
  93. * will also trigger this exception.
  94. */
  95. public boolean dispatchEvent(Event evt)
  96. throws EventException;
  97. }