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