Interface EventTarget
- All Known Subinterfaces:
BodyElement
,ButtonElement
,CanvasElement
,ComponentElement
,DelphiElement
,Document
,Element
,HeadElement
,InputElement
,ItemElement
,JavaObjectElement
,OptionElement
,ScriptElement
,StyleElement
Event
dispatches-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventListener
(String eventType, EventListener listener) Adds an event listener to the specified type.void
dispatchEvent
(Event event) Dispatches an event.Get the attribute addition listener.Get the option addition listener.Get the append listener.Get the attribute change listener.Get the left-click listener@Nullable EventListener
Get the DOM closing listener.Get the input listener.Get the DOM loaded listener.Get the mouse enter listener.Get the mouse exit listener.Get the mouse move listener.Get the option change listener.Get the attribute remove listener.Get the remove child listener.Get the option removal listener.Get the right-click listenerGet the attribute set listener.Get the option set listener.@Nullable EventListener
Get the DOM spawned listener.void
Set the attribute addition listener.void
onAddOption
(EventListener.Typed<AttributeMutateEvent> listener) Set the option addition listener.void
onAppendChild
(EventListener.Typed<MutationEvent> listener) Set the append listener.void
Set the attribute change listener.void
onClick
(EventListener.Typed<MouseEvent> listener) Set the click listener.void
onClosing
(@Nullable EventListener listener) Set the DOM closing listener.void
onInput
(EventListener.Typed<InputEvent> listener) Set the input listener.void
onLoaded
(@Nullable EventListener listener) Set the DOM loaded listener.void
onMouseEnter
(EventListener.Typed<MouseEvent> listener) Set the mouse enter listener.void
onMouseExit
(EventListener.Typed<MouseEvent> listener) Set the mouse exit listener.void
onMouseMove
(EventListener.Typed<MouseEvent> listener) Set the mouse move listener.void
Set the option change listener.void
Set the attribute removal listener.void
onRemoveChild
(EventListener.Typed<MutationEvent> listener) Set the remove child listener.void
Set the option removal listener.void
onRightClick
(EventListener.Typed<MouseEvent> listener) Set the right-click listener.void
Set the attribute set listener.void
onSetOption
(EventListener.Typed<AttributeMutateEvent> listener) Set the option set listener.void
onSpawned
(@Nullable EventListener listener) Set the DOM spawned listener.boolean
removeEventListener
(String eventType, EventListener listener) Removes an event listener.
-
Method Details
-
addEventListener
Adds an event listener to the specified type.- Parameters:
eventType
- Event typelistener
- Event listener- Throws:
NullPointerException
- if eithereventType
orlistener
isnull
-
removeEventListener
Removes an event listener.If either the
eventType
orlistener
isnull
, this return false.- Parameters:
eventType
- Event typelistener
- Event listener- Returns:
true
, if the listener was registered for the specifiedeventType
and was removed,false
otherwise.- Throws:
NullPointerException
- if eithereventType
orlistener
isnull
-
dispatchEvent
Dispatches an event.Events are executed first by the target they are dispatched on. Then, if the event is set to bubble (with
Event.isBubbling()
) then it will bubble up through the document tree.
Finally, the event will be dispatched toDocument.getGlobalTarget()
, unless the event has been cancelled.- Parameters:
event
- Event to dispatch- Throws:
NullPointerException
- ifevent
isnull
-
onClick
Set the click listener. The set listener will only be called when a player left-clicks the target.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.CLICK
events.- Parameters:
listener
- Click listener
-
getOnClick
Get the left-click listener- Returns:
- Click listener, or
null
, if not set
-
onRightClick
Set the right-click listener.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.CLICK
events.- Parameters:
listener
- Right click listener
-
getOnRightClick
Get the right-click listener- Returns:
- Click listener, or
null
, if not set
-
onMouseEnter
Set the mouse enter listener. The listener is called when a player's cursor enters the target.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MOUSE_ENTER
events.- Parameters:
listener
- Mouse enter listener
-
getOnMouseEnter
Get the mouse enter listener.- Returns:
- Mouse enter listener, or
null
, if not set
-
onMouseExit
Set the mouse exit listener. The listener is called when a player's cursor exits the target.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MOUSE_LEAVE
events.- Parameters:
listener
- Mouse exit listener
-
getOnMouseExit
Get the mouse exit listener.- Returns:
- Mouse exit listener, or
null
, if not set
-
onMouseMove
Set the mouse move listener. The listener is only called when a player's cursor moves inside the target. If a player's cursor exits or enters the target, the listener is not called.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MOUSE_MOVE
events.- Parameters:
listener
- Mouse move listener
-
getOnMouseMove
Get the mouse move listener.- Returns:
- Mouse move listener, or
null
, if not set
-
onAppendChild
Set the append listener. The listener is called when a childNode
is appended to the target.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.APPEND_CHILD
events.- Parameters:
listener
- Child append listener
-
getOnAppendChild
Get the append listener.- Returns:
- append listener, or
null
, if not set
-
onRemoveChild
Set the remove child listener. The listener is called when a childNode
is removed from the target.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.REMOVE_CHILD
events.- Parameters:
listener
- Child remove listener
-
getOnRemoveChild
Get the remove child listener.- Returns:
- remove child listener, or
null
, if not set
-
onAttributeChange
Set the attribute change listener. The listener is called whenever any change is made to an attribute's value.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MODIFY_ATTR
events.- Parameters:
listener
- Attribute listener
-
getOnAttributeChange
Get the attribute change listener.- Returns:
- attribute change listener, or
null
, if not set
-
onSetAttribute
Set the attribute set listener. The listener is called whenever an existing attribute's value is set.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MODIFY_ATTR
events.- Parameters:
listener
- Attribute set listener
-
getOnSetAttribute
Get the attribute set listener.- Returns:
- attribute set listener, or
null
, if not set
-
onRemoveAttribute
Set the attribute removal listener. The listener is called whenever an existing attribute's value is removed.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MODIFY_ATTR
events.- Parameters:
listener
-
-
getOnRemoveAttribute
Get the attribute remove listener.- Returns:
- attribute remove listener, or
null
, if not set
-
onAddAttribute
Set the attribute addition listener. The listener is called whenever a new attribute is set.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MODIFY_ATTR
events.- Parameters:
listener
- Attribute addition listener
-
getOnAddAttribute
Get the attribute addition listener.- Returns:
- attribute addition listener, or
null
, if not set
-
onOptionChange
Set the option change listener. The listener is called whenever any change is made to an document option's value.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MODIFY_OPTION
events.- Parameters:
listener
- Option listener
-
getOnOptionChange
Get the option change listener.- Returns:
- option change listener, or
null
, if not set
-
onSetOption
Set the option set listener. The listener is called whenever an existing document option's value is set.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MODIFY_OPTION
events.- Parameters:
listener
- Option set listener
-
getOnSetOption
Get the option set listener.- Returns:
- option set listener, or
null
, if not set
-
onRemoveOption
Set the option removal listener. The listener is called whenever an existing document option's value is removed.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MODIFY_OPTION
events.- Parameters:
listener
- Option remove listener
-
getOnRemoveOption
Get the option removal listener.- Returns:
- option removal listener, or
null
, if not set
-
onAddOption
Set the option addition listener. The listener is called whenever a new document option is set.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.MODIFY_OPTION
events.- Parameters:
listener
- Option addition listener
-
getOnAddOption
Get the option addition listener.- Returns:
- option addition listener, or
null
, if not set
-
onInput
Set the input listener. The listener is called whenever the input of anInputElement
is changed, either by player or by calling theInputElement.setValue(String)
method.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.INPUT
events.- Parameters:
listener
- Input listener
-
getOnInput
Get the input listener.- Returns:
- input listener, or
null
, if not set
-
onLoaded
Set the DOM loaded listener. The listener is called when the DOM tree is finished loading.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.DOM_LOADED
events.- Parameters:
listener
- DOM loaded listener
-
getOnLoaded
Get the DOM loaded listener.- Returns:
- DOM loaded listener, or
null
, if not set
-
onSpawned
Set the DOM spawned listener. The listener is called when the document view is spawned and becomes visible to players.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.DOM_SPAWNED
events.- Parameters:
listener
- Spawn listener
-
getOnSpawned
Get the DOM spawned listener.- Returns:
- DOM spawned listener, or
null
, if not set
-
onClosing
Set the DOM closing listener. The listener is called when the document view starts closing.Can be removed by setting this to
null
and overridden by calling this method againListens to
EventTypes.DOM_CLOSING
events.- Parameters:
listener
- Closing listener
-
getOnClosing
Get the DOM closing listener.- Returns:
- DOM closing listener, or
null
, if not set
-