6
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
|
6 |
* published by the Free Software Foundation. Sun designates this
|
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
|
8 |
* by Sun in the LICENSE file that accompanied this code.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
21 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
22 |
* have any questions.
|
|
23 |
*/
|
|
24 |
|
|
25 |
/*
|
|
26 |
* This file is available under and governed by the GNU General Public
|
|
27 |
* License version 2 only, as published by the Free Software Foundation.
|
|
28 |
* However, the following notice accompanied the original version of this
|
|
29 |
* file and, per its terms, should not be removed:
|
|
30 |
*
|
|
31 |
* Copyright (c) 2000 World Wide Web Consortium,
|
|
32 |
* (Massachusetts Institute of Technology, Institut National de
|
|
33 |
* Recherche en Informatique et en Automatique, Keio University). All
|
|
34 |
* Rights Reserved. This program is distributed under the W3C's Software
|
|
35 |
* Intellectual Property License. This program is distributed in the
|
|
36 |
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
37 |
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
38 |
* PURPOSE.
|
|
39 |
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
|
|
40 |
*/
|
|
41 |
|
|
42 |
package org.w3c.dom.events;
|
|
43 |
|
|
44 |
/**
|
|
45 |
* The <code>EventTarget</code> interface is implemented by all
|
|
46 |
* <code>Nodes</code> in an implementation which supports the DOM Event
|
|
47 |
* Model. Therefore, this interface can be obtained by using
|
|
48 |
* binding-specific casting methods on an instance of the <code>Node</code>
|
|
49 |
* interface. The interface allows registration and removal of
|
|
50 |
* <code>EventListeners</code> on an <code>EventTarget</code> and dispatch
|
|
51 |
* of events to that <code>EventTarget</code>.
|
|
52 |
* <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>.
|
|
53 |
* @since DOM Level 2
|
|
54 |
*/
|
|
55 |
public interface EventTarget {
|
|
56 |
/**
|
|
57 |
* This method allows the registration of event listeners on the event
|
|
58 |
* target. If an <code>EventListener</code> is added to an
|
|
59 |
* <code>EventTarget</code> while it is processing an event, it will not
|
|
60 |
* be triggered by the current actions but may be triggered during a
|
|
61 |
* later stage of event flow, such as the bubbling phase.
|
|
62 |
* <br> If multiple identical <code>EventListener</code>s are registered
|
|
63 |
* on the same <code>EventTarget</code> with the same parameters the
|
|
64 |
* duplicate instances are discarded. They do not cause the
|
|
65 |
* <code>EventListener</code> to be called twice and since they are
|
|
66 |
* discarded they do not need to be removed with the
|
|
67 |
* <code>removeEventListener</code> method.
|
|
68 |
* @param type The event type for which the user is registering
|
|
69 |
* @param listener The <code>listener</code> parameter takes an interface
|
|
70 |
* implemented by the user which contains the methods to be called
|
|
71 |
* when the event occurs.
|
|
72 |
* @param useCapture If true, <code>useCapture</code> indicates that the
|
|
73 |
* user wishes to initiate capture. After initiating capture, all
|
|
74 |
* events of the specified type will be dispatched to the registered
|
|
75 |
* <code>EventListener</code> before being dispatched to any
|
|
76 |
* <code>EventTargets</code> beneath them in the tree. Events which
|
|
77 |
* are bubbling upward through the tree will not trigger an
|
|
78 |
* <code>EventListener</code> designated to use capture.
|
|
79 |
*/
|
|
80 |
public void addEventListener(String type,
|
|
81 |
EventListener listener,
|
|
82 |
boolean useCapture);
|
|
83 |
|
|
84 |
/**
|
|
85 |
* This method allows the removal of event listeners from the event
|
|
86 |
* target. If an <code>EventListener</code> is removed from an
|
|
87 |
* <code>EventTarget</code> while it is processing an event, it will not
|
|
88 |
* be triggered by the current actions. <code>EventListener</code>s can
|
|
89 |
* never be invoked after being removed.
|
|
90 |
* <br>Calling <code>removeEventListener</code> with arguments which do
|
|
91 |
* not identify any currently registered <code>EventListener</code> on
|
|
92 |
* the <code>EventTarget</code> has no effect.
|
|
93 |
* @param type Specifies the event type of the <code>EventListener</code>
|
|
94 |
* being removed.
|
|
95 |
* @param listener The <code>EventListener</code> parameter indicates the
|
|
96 |
* <code>EventListener </code> to be removed.
|
|
97 |
* @param useCapture Specifies whether the <code>EventListener</code>
|
|
98 |
* being removed was registered as a capturing listener or not. If a
|
|
99 |
* listener was registered twice, one with capture and one without,
|
|
100 |
* each must be removed separately. Removal of a capturing listener
|
|
101 |
* does not affect a non-capturing version of the same listener, and
|
|
102 |
* vice versa.
|
|
103 |
*/
|
|
104 |
public void removeEventListener(String type,
|
|
105 |
EventListener listener,
|
|
106 |
boolean useCapture);
|
|
107 |
|
|
108 |
/**
|
|
109 |
* This method allows the dispatch of events into the implementations
|
|
110 |
* event model. Events dispatched in this manner will have the same
|
|
111 |
* capturing and bubbling behavior as events dispatched directly by the
|
|
112 |
* implementation. The target of the event is the
|
|
113 |
* <code> EventTarget</code> on which <code>dispatchEvent</code> is
|
|
114 |
* called.
|
|
115 |
* @param evt Specifies the event type, behavior, and contextual
|
|
116 |
* information to be used in processing the event.
|
|
117 |
* @return The return value of <code>dispatchEvent</code> indicates
|
|
118 |
* whether any of the listeners which handled the event called
|
|
119 |
* <code>preventDefault</code>. If <code>preventDefault</code> was
|
|
120 |
* called the value is false, else the value is true.
|
|
121 |
* @exception EventException
|
|
122 |
* UNSPECIFIED_EVENT_TYPE_ERR: Raised if the <code>Event</code>'s type
|
|
123 |
* was not specified by initializing the event before
|
|
124 |
* <code>dispatchEvent</code> was called. Specification of the
|
|
125 |
* <code>Event</code>'s type as <code>null</code> or an empty string
|
|
126 |
* will also trigger this exception.
|
|
127 |
*/
|
|
128 |
public boolean dispatchEvent(Event evt)
|
|
129 |
throws EventException;
|
|
130 |
|
|
131 |
}
|