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