1//
2// EventTarget.h
3//
4// Library: XML
5// Package: DOM
6// Module: DOMEvents
7//
8// Definition of the DOM EventTarget interface.
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef DOM_EventTarget_INCLUDED
18#define DOM_EventTarget_INCLUDED
19
20
21#include "Poco/XML/XML.h"
22#include "Poco/DOM/DOMObject.h"
23#include "Poco/XML/XMLString.h"
24
25
26namespace Poco {
27namespace XML {
28
29
30class EventListener;
31class Event;
32
33
34class XML_API EventTarget: public DOMObject
35 /// The EventTarget interface is implemented by all Nodes in an implementation
36 /// which supports the DOM Event Model. Therefore, this interface can be obtained
37 /// by using binding-specific casting methods on an instance of the Node interface.
38 /// The interface allows registration and removal of EventListeners on an EventTarget
39 /// and dispatch of events to that EventTarget.
40{
41public:
42 virtual void addEventListener(const XMLString& type, EventListener* listener, bool useCapture) = 0;
43 /// This method allows the registration of event listeners on
44 /// the event target. If an EventListener is added to an
45 /// EventTarget while it is processing an event, it will not
46 /// be triggered by the current actions but may be triggered
47 /// during a later stage of event flow, such as the bubbling phase.
48 /// If multiple identical EventListeners are registered on the same
49 /// EventTarget with the same parameters the duplicate instances are
50 /// discarded. They do not cause the EventListener to be called twice and since they are
51 /// discarded they do not need to be removed with the removeEventListener method.
52
53 virtual void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture) = 0;
54 /// This method allows the removal of event listeners from the event
55 /// target. If an EventListener is removed from an EventTarget while it is
56 /// processing an event, it will not be triggered by the current actions.
57 /// EventListeners can never be invoked after being removed.
58 /// Calling removeEventListener with arguments which do not identify
59 /// any currently registered EventListener on the EventTarget has no effect.
60
61 virtual bool dispatchEvent(Event* evt) = 0;
62 /// This method allows the dispatch of events into the implementations
63 /// event model. Events dispatched in this manner will have the same capturing and
64 /// bubbling behavior as events dispatched directly by the
65 /// implementation. The target of the event is the EventTarget on
66 /// which dispatchEvent is called.
67
68protected:
69 virtual ~EventTarget();
70};
71
72
73} } // namespace Poco::XML
74
75
76#endif // DOM_EventTarget_INCLUDED
77