EventTarget.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef DOM_EventTarget_INCLUDED
  16. #define DOM_EventTarget_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/DOM/DOMObject.h"
  19. #include "Poco/XML/XMLString.h"
  20. namespace Poco {
  21. namespace XML {
  22. class EventListener;
  23. class Event;
  24. class XML_API EventTarget: public DOMObject
  25. /// The EventTarget interface is implemented by all Nodes in an implementation
  26. /// which supports the DOM Event Model. Therefore, this interface can be obtained
  27. /// by using binding-specific casting methods on an instance of the Node interface.
  28. /// The interface allows registration and removal of EventListeners on an EventTarget
  29. /// and dispatch of events to that EventTarget.
  30. {
  31. public:
  32. virtual void addEventListener(const XMLString& type, EventListener* listener, bool useCapture) = 0;
  33. /// This method allows the registration of event listeners on
  34. /// the event target. If an EventListener is added to an
  35. /// EventTarget while it is processing an event, it will not
  36. /// be triggered by the current actions but may be triggered
  37. /// during a later stage of event flow, such as the bubbling phase.
  38. /// If multiple identical EventListeners are registered on the same
  39. /// EventTarget with the same parameters the duplicate instances are
  40. /// discarded. They do not cause the EventListener to be called twice and since they are
  41. /// discarded they do not need to be removed with the removeEventListener method.
  42. virtual void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture) = 0;
  43. /// This method allows the removal of event listeners from the event
  44. /// target. If an EventListener is removed from an EventTarget while it is
  45. /// processing an event, it will not be triggered by the current actions.
  46. /// EventListeners can never be invoked after being removed.
  47. /// Calling removeEventListener with arguments which do not identify
  48. /// any currently registered EventListener on the EventTarget has no effect.
  49. virtual bool dispatchEvent(Event* evt) = 0;
  50. /// This method allows the dispatch of events into the implementations
  51. /// event model. Events dispatched in this manner will have the same capturing and
  52. /// bubbling behavior as events dispatched directly by the
  53. /// implementation. The target of the event is the EventTarget on
  54. /// which dispatchEvent is called.
  55. protected:
  56. virtual ~EventTarget();
  57. };
  58. } } // namespace Poco::XML
  59. #endif // DOM_EventTarget_INCLUDED