001 /*
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
003 *
004 * This code is free software; you can redistribute it and/or modify it
005 * under the terms of the GNU General Public License version 2 only, as
006 * published by the Free Software Foundation. Sun designates this
007 * particular file as subject to the "Classpath" exception as provided
008 * by Sun in the LICENSE file that accompanied this code.
009 *
010 * This code is distributed in the hope that it will be useful, but WITHOUT
011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
013 * version 2 for more details (a copy is included in the LICENSE file that
014 * accompanied this code).
015 *
016 * You should have received a copy of the GNU General Public License version
017 * 2 along with this work; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
019 *
020 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
021 * CA 95054 USA or visit www.sun.com if you need additional information or
022 * have any questions.
023 */
024
025 /*
026 * This file is available under and governed by the GNU General Public
027 * License version 2 only, as published by the Free Software Foundation.
028 * However, the following notice accompanied the original version of this
029 * file and, per its terms, should not be removed:
030 *
031 * Copyright (c) 2000 World Wide Web Consortium,
032 * (Massachusetts Institute of Technology, Institut National de
033 * Recherche en Informatique et en Automatique, Keio University). All
034 * Rights Reserved. This program is distributed under the W3C's Software
035 * Intellectual Property License. This program is distributed in the
036 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
037 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
038 * PURPOSE.
039 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
040 */
041
042 package org.w3c.dom.events;
043
044 /**
045 * The <code>Event</code> interface is used to provide contextual information
046 * about an event to the handler processing the event. An object which
047 * implements the <code>Event</code> interface is generally passed as the
048 * first parameter to an event handler. More specific context information is
049 * passed to event handlers by deriving additional interfaces from
050 * <code>Event</code> which contain information directly relating to the
051 * type of event they accompany. These derived interfaces are also
052 * implemented by the object passed to the event listener.
053 * <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>.
054 * @since DOM Level 2
055 */
056 public interface Event {
057 // PhaseType
058 /**
059 * The current event phase is the capturing phase.
060 */
061 public static final short CAPTURING_PHASE = 1;
062 /**
063 * The event is currently being evaluated at the target
064 * <code>EventTarget</code>.
065 */
066 public static final short AT_TARGET = 2;
067 /**
068 * The current event phase is the bubbling phase.
069 */
070 public static final short BUBBLING_PHASE = 3;
071
072 /**
073 * The name of the event (case-insensitive). The name must be an XML name.
074 */
075 public String getType();
076
077 /**
078 * Used to indicate the <code>EventTarget</code> to which the event was
079 * originally dispatched.
080 */
081 public EventTarget getTarget();
082
083 /**
084 * Used to indicate the <code>EventTarget</code> whose
085 * <code>EventListeners</code> are currently being processed. This is
086 * particularly useful during capturing and bubbling.
087 */
088 public EventTarget getCurrentTarget();
089
090 /**
091 * Used to indicate which phase of event flow is currently being
092 * evaluated.
093 */
094 public short getEventPhase();
095
096 /**
097 * Used to indicate whether or not an event is a bubbling event. If the
098 * event can bubble the value is true, else the value is false.
099 */
100 public boolean getBubbles();
101
102 /**
103 * Used to indicate whether or not an event can have its default action
104 * prevented. If the default action can be prevented the value is true,
105 * else the value is false.
106 */
107 public boolean getCancelable();
108
109 /**
110 * Used to specify the time (in milliseconds relative to the epoch) at
111 * which the event was created. Due to the fact that some systems may
112 * not provide this information the value of <code>timeStamp</code> may
113 * be not available for all events. When not available, a value of 0
114 * will be returned. Examples of epoch time are the time of the system
115 * start or 0:0:0 UTC 1st January 1970.
116 */
117 public long getTimeStamp();
118
119 /**
120 * The <code>stopPropagation</code> method is used prevent further
121 * propagation of an event during event flow. If this method is called
122 * by any <code>EventListener</code> the event will cease propagating
123 * through the tree. The event will complete dispatch to all listeners
124 * on the current <code>EventTarget</code> before event flow stops. This
125 * method may be used during any stage of event flow.
126 */
127 public void stopPropagation();
128
129 /**
130 * If an event is cancelable, the <code>preventDefault</code> method is
131 * used to signify that the event is to be canceled, meaning any default
132 * action normally taken by the implementation as a result of the event
133 * will not occur. If, during any stage of event flow, the
134 * <code>preventDefault</code> method is called the event is canceled.
135 * Any default action associated with the event will not occur. Calling
136 * this method for a non-cancelable event has no effect. Once
137 * <code>preventDefault</code> has been called it will remain in effect
138 * throughout the remainder of the event's propagation. This method may
139 * be used during any stage of event flow.
140 */
141 public void preventDefault();
142
143 /**
144 * The <code>initEvent</code> method is used to initialize the value of an
145 * <code>Event</code> created through the <code>DocumentEvent</code>
146 * interface. This method may only be called before the
147 * <code>Event</code> has been dispatched via the
148 * <code>dispatchEvent</code> method, though it may be called multiple
149 * times during that phase if necessary. If called multiple times the
150 * final invocation takes precedence. If called from a subclass of
151 * <code>Event</code> interface only the values specified in the
152 * <code>initEvent</code> method are modified, all other attributes are
153 * left unchanged.
154 * @param eventTypeArg Specifies the event type. This type may be any
155 * event type currently defined in this specification or a new event
156 * type.. The string must be an XML name. Any new event type must not
157 * begin with any upper, lower, or mixed case version of the string
158 * "DOM". This prefix is reserved for future DOM event sets. It is
159 * also strongly recommended that third parties adding their own
160 * events use their own prefix to avoid confusion and lessen the
161 * probability of conflicts with other new events.
162 * @param canBubbleArg Specifies whether or not the event can bubble.
163 * @param cancelableArg Specifies whether or not the event's default
164 * action can be prevented.
165 */
166 public void initEvent(String eventTypeArg, boolean canBubbleArg,
167 boolean cancelableArg);
168
169 }
|