1f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson/*
2f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * Copyright (c) 2000 World Wide Web Consortium,
3f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * (Massachusetts Institute of Technology, Institut National de
4f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * Recherche en Informatique et en Automatique, Keio University). All
5f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * Rights Reserved. This program is distributed under the W3C's Software
6f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * Intellectual Property License. This program is distributed in the
7f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * PURPOSE.
10f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
11f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson */
12f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
13f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilsonpackage org.w3c.dom.events;
14f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
15f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson/**
16f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * The <code>Event</code> interface is used to provide contextual information
17f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * about an event to the handler processing the event. An object which
18f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * implements the <code>Event</code> interface is generally passed as the
19f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * first parameter to an event handler. More specific context information is
20f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * passed to event handlers by deriving additional interfaces from
21f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>Event</code> which contain information directly relating to the
22f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * type of event they accompany. These derived interfaces are also
23f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * implemented by the object passed to the event listener.
24f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <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>.
25f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @since DOM Level 2
26f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson */
27f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilsonpublic interface Event {
28f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    // PhaseType
29f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
30f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * The current event phase is the capturing phase.
31f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
32f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public static final short CAPTURING_PHASE           = 1;
33f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
34f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * The event is currently being evaluated at the target
35f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * <code>EventTarget</code>.
36f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
37f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public static final short AT_TARGET                 = 2;
38f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
39f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * The current event phase is the bubbling phase.
40f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
41f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public static final short BUBBLING_PHASE            = 3;
42f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
43f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
44f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * The name of the event (case-insensitive). The name must be an XML name.
45f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
46f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public String getType();
47f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
48f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
49f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * Used to indicate the <code>EventTarget</code> to which the event was
50f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * originally dispatched.
51f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
52f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public EventTarget getTarget();
53f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
54f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
55f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * Used to indicate the <code>EventTarget</code> whose
56f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * <code>EventListeners</code> are currently being processed. This is
57f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * particularly useful during capturing and bubbling.
58f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
59f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public EventTarget getCurrentTarget();
60f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
61f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
62f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * Used to indicate which phase of event flow is currently being
63f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * evaluated.
64f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
65f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public short getEventPhase();
66f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
67f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
68f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * Used to indicate whether or not an event is a bubbling event. If the
69f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * event can bubble the value is true, else the value is false.
70f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
71f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public boolean getBubbles();
72f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
73f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
74f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * Used to indicate whether or not an event can have its default action
75f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * prevented. If the default action can be prevented the value is true,
76f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * else the value is false.
77f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
78f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public boolean getCancelable();
79f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
80f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
81f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     *  Used to specify the time (in milliseconds relative to the epoch) at
82f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * which the event was created. Due to the fact that some systems may
83f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * not provide this information the value of <code>timeStamp</code> may
84f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * be not available for all events. When not available, a value of 0
85f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * will be returned. Examples of epoch time are the time of the system
86f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * start or 0:0:0 UTC 1st January 1970.
87f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
88f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public long getTimeStamp();
89f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
90f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
91f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * The <code>stopPropagation</code> method is used prevent further
92f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * propagation of an event during event flow. If this method is called
93f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * by any <code>EventListener</code> the event will cease propagating
94f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * through the tree. The event will complete dispatch to all listeners
95f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * on the current <code>EventTarget</code> before event flow stops. This
96f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * method may be used during any stage of event flow.
97f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
98f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public void stopPropagation();
99f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
100f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
101f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * If an event is cancelable, the <code>preventDefault</code> method is
102f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * used to signify that the event is to be canceled, meaning any default
103f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * action normally taken by the implementation as a result of the event
104f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * will not occur. If, during any stage of event flow, the
105f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * <code>preventDefault</code> method is called the event is canceled.
106f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * Any default action associated with the event will not occur. Calling
107f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * this method for a non-cancelable event has no effect. Once
108f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * <code>preventDefault</code> has been called it will remain in effect
109f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * throughout the remainder of the event's propagation. This method may
110f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * be used during any stage of event flow.
111f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
112f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public void preventDefault();
113f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
114f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    /**
115f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * The <code>initEvent</code> method is used to initialize the value of an
116f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * <code>Event</code> created through the <code>DocumentEvent</code>
117f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * interface. This method may only be called before the
118f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * <code>Event</code> has been dispatched via the
119f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * <code>dispatchEvent</code> method, though it may be called multiple
120f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * times during that phase if necessary. If called multiple times the
121f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * final invocation takes precedence. If called from a subclass of
122f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * <code>Event</code> interface only the values specified in the
123f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * <code>initEvent</code> method are modified, all other attributes are
124f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * left unchanged.
125f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * @param eventTypeArg Specifies the event type. This type may be any
126f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     *   event type currently defined in this specification or a new event
127f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     *   type.. The string must be an XML name. Any new event type must not
128f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     *   begin with any upper, lower, or mixed case version of the string
129f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     *   "DOM". This prefix is reserved for future DOM event sets. It is
130f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     *   also strongly recommended that third parties adding their own
131f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     *   events use their own prefix to avoid confusion and lessen the
132f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     *   probability of conflicts with other new events.
133f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * @param canBubbleArg Specifies whether or not the event can bubble.
134f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     * @param cancelableArg Specifies whether or not the event's default
135f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     *   action can be prevented.
136f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson     */
137f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson    public void initEvent(String eventTypeArg,
138f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson                          boolean canBubbleArg,
139f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson                          boolean cancelableArg);
140f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson
141f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson}
142