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>EventTarget</code> interface is implemented by all 17f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>Nodes</code> in an implementation which supports the DOM Event 18f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * Model. Therefore, this interface can be obtained by using 19f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * binding-specific casting methods on an instance of the <code>Node</code> 20f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * interface. The interface allows registration and removal of 21f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>EventListeners</code> on an <code>EventTarget</code> and dispatch 22f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * of events to that <code>EventTarget</code>. 23f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse 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>. 24f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @since DOM Level 2 25f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson */ 26f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilsonpublic interface EventTarget { 27f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson /** 28f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * This method allows the registration of event listeners on the event 29f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * target. If an <code>EventListener</code> is added to an 30f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>EventTarget</code> while it is processing an event, it will not 31f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * be triggered by the current actions but may be triggered during a 32f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * later stage of event flow, such as the bubbling phase. 33f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <br> If multiple identical <code>EventListener</code>s are registered 34f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * on the same <code>EventTarget</code> with the same parameters the 35f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * duplicate instances are discarded. They do not cause the 36f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>EventListener</code> to be called twice and since they are 37f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * discarded they do not need to be removed with the 38f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>removeEventListener</code> method. 39f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @param type The event type for which the user is registering 40f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @param listener The <code>listener</code> parameter takes an interface 41f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * implemented by the user which contains the methods to be called 42f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * when the event occurs. 43f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @param useCapture If true, <code>useCapture</code> indicates that the 44f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * user wishes to initiate capture. After initiating capture, all 45f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * events of the specified type will be dispatched to the registered 46f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>EventListener</code> before being dispatched to any 47f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>EventTargets</code> beneath them in the tree. Events which 48f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * are bubbling upward through the tree will not trigger an 49f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>EventListener</code> designated to use capture. 50f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson */ 51f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson public void addEventListener(String type, 52f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson EventListener listener, 53f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson boolean useCapture); 54f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson 55f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson /** 56f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * This method allows the removal of event listeners from the event 57f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * target. If an <code>EventListener</code> is removed from an 58f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>EventTarget</code> while it is processing an event, it will not 59f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * be triggered by the current actions. <code>EventListener</code>s can 60f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * never be invoked after being removed. 61f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <br>Calling <code>removeEventListener</code> with arguments which do 62f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * not identify any currently registered <code>EventListener</code> on 63f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * the <code>EventTarget</code> has no effect. 64f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @param type Specifies the event type of the <code>EventListener</code> 65f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * being removed. 66f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @param listener The <code>EventListener</code> parameter indicates the 67f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>EventListener </code> to be removed. 68f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @param useCapture Specifies whether the <code>EventListener</code> 69f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * being removed was registered as a capturing listener or not. If a 70f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * listener was registered twice, one with capture and one without, 71f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * each must be removed separately. Removal of a capturing listener 72f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * does not affect a non-capturing version of the same listener, and 73f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * vice versa. 74f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson */ 75f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson public void removeEventListener(String type, 76f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson EventListener listener, 77f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson boolean useCapture); 78f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson 79f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson /** 80f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * This method allows the dispatch of events into the implementations 81f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * event model. Events dispatched in this manner will have the same 82f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * capturing and bubbling behavior as events dispatched directly by the 83f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * implementation. The target of the event is the 84f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code> EventTarget</code> on which <code>dispatchEvent</code> is 85f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * called. 86f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @param evt Specifies the event type, behavior, and contextual 87f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * information to be used in processing the event. 88f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @return The return value of <code>dispatchEvent</code> indicates 89f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * whether any of the listeners which handled the event called 90f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>preventDefault</code>. If <code>preventDefault</code> was 91f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * called the value is false, else the value is true. 92f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * @exception EventException 93f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * UNSPECIFIED_EVENT_TYPE_ERR: Raised if the <code>Event</code>'s type 94f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * was not specified by initializing the event before 95f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>dispatchEvent</code> was called. Specification of the 96f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * <code>Event</code>'s type as <code>null</code> or an empty string 97f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson * will also trigger this exception. 98f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson */ 99f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson public boolean dispatchEvent(Event evt) 100f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson throws EventException; 101f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson 102f4ce5c4028bf4001cd718df83d5641913ca9c928Jesse Wilson} 103