Interface EventTarget
-
- All Known Subinterfaces:
ExtendedNode,NodeEventTarget
- All Known Implementing Classes:
AbstractAttr,AbstractAttrNS,AbstractCharacterData,AbstractChildNode,AbstractComment,AbstractDocument,AbstractDocumentFragment,AbstractElement,AbstractElement,AbstractElementNS,AbstractEntity,AbstractEntityReference,AbstractNode,AbstractNotation,AbstractParentChildNode,AbstractParentNode,AbstractProcessingInstruction,AbstractStylableDocument,AbstractText,BatikHistogramNormalizationElement,BatikRegularPolygonElement,BatikStarElement,BindableElement,ColorSwitchElement,ExtensionElement,FlowDivElement,FlowLineElement,FlowParaElement,FlowRegionBreakElement,FlowRegionElement,FlowSpanElement,FlowTextElement,GenericAttr,GenericAttrNS,GenericCDATASection,GenericComment,GenericDocument,GenericDocumentFragment,GenericDocumentType,GenericElement,GenericElementNS,GenericEntity,GenericEntityReference,GenericNotation,GenericProcessingInstruction,GenericText,GraphicsExtensionElement,PrefixableStylableExtensionElement,StylableExtensionElement,StyleSheetProcessingInstruction,SVG12OMDocument,SVGDescriptiveElement,SVGGraphicsElement,SVGOMAElement,SVGOMAltGlyphDefElement,SVGOMAltGlyphElement,SVGOMAltGlyphItemElement,SVGOMAnimateColorElement,SVGOMAnimateElement,SVGOMAnimateMotionElement,SVGOMAnimateTransformElement,SVGOMAnimationElement,SVGOMCircleElement,SVGOMClipPathElement,SVGOMColorProfileElement,SVGOMComponentTransferFunctionElement,SVGOMCursorElement,SVGOMDefinitionSrcElement,SVGOMDefsElement,SVGOMDescElement,SVGOMDocument,SVGOMElement,SVGOMEllipseElement,SVGOMFEBlendElement,SVGOMFEColorMatrixElement,SVGOMFEComponentTransferElement,SVGOMFECompositeElement,SVGOMFEConvolveMatrixElement,SVGOMFEDiffuseLightingElement,SVGOMFEDisplacementMapElement,SVGOMFEDistantLightElement,SVGOMFEFloodElement,SVGOMFEFuncAElement,SVGOMFEFuncBElement,SVGOMFEFuncGElement,SVGOMFEFuncRElement,SVGOMFEGaussianBlurElement,SVGOMFEImageElement,SVGOMFEMergeElement,SVGOMFEMergeNodeElement,SVGOMFEMorphologyElement,SVGOMFEOffsetElement,SVGOMFEPointLightElement,SVGOMFESpecularLightingElement,SVGOMFESpotLightElement,SVGOMFETileElement,SVGOMFETurbulenceElement,SVGOMFilterElement,SVGOMFilterPrimitiveStandardAttributes,SVGOMFlowDivElement,SVGOMFlowLineElement,SVGOMFlowParaElement,SVGOMFlowRegionBreakElement,SVGOMFlowRegionElement,SVGOMFlowRegionExcludeElement,SVGOMFlowRootElement,SVGOMFlowSpanElement,SVGOMFontElement,SVGOMFontFaceElement,SVGOMFontFaceFormatElement,SVGOMFontFaceNameElement,SVGOMFontFaceSrcElement,SVGOMFontFaceUriElement,SVGOMForeignObjectElement,SVGOMGElement,SVGOMGlyphElement,SVGOMGlyphRefElement,SVGOMGradientElement,SVGOMHandlerElement,SVGOMHKernElement,SVGOMImageElement,SVGOMLinearGradientElement,SVGOMLineElement,SVGOMMarkerElement,SVGOMMaskElement,SVGOMMetadataElement,SVGOMMissingGlyphElement,SVGOMMPathElement,SVGOMMultiImageElement,SVGOMPathElement,SVGOMPatternElement,SVGOMPolygonElement,SVGOMPolylineElement,SVGOMRadialGradientElement,SVGOMRectElement,SVGOMScriptElement,SVGOMSetElement,SVGOMSolidColorElement,SVGOMStopElement,SVGOMStyleElement,SVGOMSubImageElement,SVGOMSubImageRefElement,SVGOMSVGElement,SVGOMSwitchElement,SVGOMSymbolElement,SVGOMTextContentElement,SVGOMTextElement,SVGOMTextPathElement,SVGOMTextPositioningElement,SVGOMTitleElement,SVGOMToBeImplementedElement,SVGOMTRefElement,SVGOMTSpanElement,SVGOMURIReferenceElement,SVGOMUseElement,SVGOMUseShadowRoot,SVGOMViewElement,SVGOMVKernElement,SVGPointShapeElement,SVGStylableElement,SVGStyleSheetProcessingInstruction,SVGURIReferenceGraphicsElement,SVGURIReferenceTextPositioningElement,XBLOMContentElement,XBLOMDefinitionElement,XBLOMElement,XBLOMHandlerGroupElement,XBLOMImportElement,XBLOMShadowTreeElement,XBLOMTemplateElement,XBLOMXBLElement
public interface EventTargetTheEventTargetinterface is implemented by all the objects which could be event targets in an implementation which supports the . The interface allows registration and removal of event listeners, and dispatch of events to an event target.When used with , this interface is implemented by all target nodes and target ancestors, i.e. all DOM
Nodesof the tree support this interface when the implementation conforms to DOM Level 3 Events and, therefore, this interface can be obtained by using binding-specific casting methods on an instance of theNodeinterface.Invoking
addEventListeneroraddEventListenerNSrepeatedly on the sameEventTargetwith the same values for the parametersnamespaceURI,type,listener, anduseCapturehas no effect. Doing so does not cause theEventListenerto be called more than once and does not cause a change in the triggering order. In order to register a listener for a different event group () the previously registered listener has to be removed first.See also the Document Object Model (DOM) Level 3 Events Specification .
- Since:
- DOM Level 2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddEventListener(java.lang.String type, EventListener listener, boolean useCapture)This method allows the registration of an event listener in the default group and, depending on theuseCaptureparameter, on the capture phase of the DOM event flow or its target and bubbling phases.voidaddEventListenerNS(java.lang.String namespaceURI, java.lang.String type, EventListener listener, boolean useCapture, java.lang.Object evtGroup)This method allows the registration of an event listener in a specified group or the default group and, depending on theuseCaptureparameter, on the capture phase of the DOM event flow or its target and bubbling phases.booleandispatchEvent(Event evt)This method allows the dispatch of events into the implementation's event model.voidremoveEventListener(java.lang.String type, EventListener listener, boolean useCapture)This method allows the removal of event listeners from the default group.voidremoveEventListenerNS(java.lang.String namespaceURI, java.lang.String type, EventListener listener, boolean useCapture)This method allows the removal of an event listener, independently of the associated event group.
-
-
-
Method Detail
-
addEventListener
void addEventListener(java.lang.String type, EventListener listener, boolean useCapture)This method allows the registration of an event listener in the default group and, depending on theuseCaptureparameter, on the capture phase of the DOM event flow or its target and bubbling phases. Invoking this method is equivalent to invokingaddEventListenerNSwith the same values for the parameterstype,listener, anduseCapture, and the valuenullfor the parametersnamespaceURIandevtGroup.- Parameters:
type- Specifies theEvent.typeassociated with the event for which the user is registering.listener- Thelistenerparameter takes an object implemented by the user which implements theEventListenerinterface and contains the method to be called when the event occurs.useCapture- If true,useCaptureindicates that the user wishes to add the event listener for the capture phase only, i.e. this event listener will not be triggered during the target and bubbling phases. Iffalse, the event listener will only be triggered during the target and bubbling phases.
-
removeEventListener
void removeEventListener(java.lang.String type, EventListener listener, boolean useCapture)This method allows the removal of event listeners from the default group. CallingremoveEventListenerwith arguments which do not identify any currently registeredEventListeneron theEventTargethas no effect. TheEvent.namespaceURIfor which the user registered the event listener is implied and isnull.Note: Event listeners registered for other event groups than the default group cannot be removed using this method; see
EventTarget.removeEventListenerNS()for that effect.- Parameters:
type- Specifies theEvent.typefor which the user registered the event listener.listener- TheEventListenerto be removed.useCapture- Specifies whether theEventListenerbeing removed was registered for the capture phase or not. If a listener was registered twice, once for the capture phase and once for the target and bubbling phases, each must be removed separately. Removal of an event listener registered for the capture phase does not affect the same event listener registered for the target and bubbling phases, and vice versa.
-
dispatchEvent
boolean dispatchEvent(Event evt) throws EventException, org.w3c.dom.DOMException
This method allows the dispatch of events into the implementation's event model. The event target of the event is theEventTargetobject on whichdispatchEventis called.- Parameters:
evt- The event to be dispatched.- Returns:
- Indicates whether any of the listeners which handled the
event called
Event.preventDefault(). IfEvent.preventDefault()was called the returned value isfalse, else it istrue. - Throws:
EventException- UNSPECIFIED_EVENT_TYPE_ERR: Raised if theEvent.typewas not specified by initializing the event beforedispatchEventwas called. Specification of theEvent.typeasnullor an empty string will also trigger this exception.
DISPATCH_REQUEST_ERR: Raised if theEventobject is already being dispatched.org.w3c.dom.DOMException- NOT_SUPPORTED_ERR: Raised if theEventobject has not been created usingDocumentEvent.createEvent().
INVALID_CHARACTER_ERR: Raised ifEvent.typeis not an NCName as defined in [XML Namespaces 1.1] .
-
addEventListenerNS
void addEventListenerNS(java.lang.String namespaceURI, java.lang.String type, EventListener listener, boolean useCapture, java.lang.Object evtGroup)This method allows the registration of an event listener in a specified group or the default group and, depending on theuseCaptureparameter, on the capture phase of the DOM event flow or its target and bubbling phases.- Parameters:
namespaceURI- Specifies theEvent.namespaceURIassociated with the event for which the user is registering.type- Refer to theEventTarget.addEventListener()method for a description of this parameter.listener- Refer to theEventTarget.addEventListener()method for a description of this parameter.useCapture- Refer to theEventTarget.addEventListener()method for a description of this parameter.evtGroup- The object that represents the event group to associate with theEventListener(see also ). Usenullto attach the event listener to the default group.- Since:
- DOM Level 3
-
removeEventListenerNS
void removeEventListenerNS(java.lang.String namespaceURI, java.lang.String type, EventListener listener, boolean useCapture)This method allows the removal of an event listener, independently of the associated event group. CallingremoveEventListenerNSwith arguments which do not identify any currently registeredEventListeneron theEventTargethas no effect.- Parameters:
namespaceURI- Specifies theEvent.namespaceURIassociated with the event for which the user registered the event listener.type- Refer to theEventTarget.removeEventListener()method for a description of this parameter.listener- Refer to theEventTarget.removeEventListener()method for a description of this parameter.useCapture- Refer to theEventTarget.removeEventListener()method for a description of this parameter.- Since:
- DOM Level 3
-
-