class EE::Scene::Node¶
Overview¶
Core node class for scene graph management. More…
#include <node.hpp> class Node: public EE::Math::Transformable { public: // typedefs typedef std::function<void(const Event*)> EventCallback; // construction virtual ~Node(); // methods static Node* New(); virtual void worldToNodeTranslation(Vector2f& position) const; virtual void nodeToWorldTranslation(Vector2f& position) const; virtual void worldToNode(Vector2i& pos) const; virtual void nodeToWorld(Vector2i& pos) const; virtual void worldToNode(Vector2f& pos) const; virtual void nodeToWorld(Vector2f& pos) const; virtual Uint32 getType() const; virtual bool isType(const Uint32& type) const; void messagePost(const NodeMessage* Msg); virtual void setPosition(const Vector2f& Pos); virtual Node* setPosition(const Float& x, const Float& y); virtual Node* setSize(const Sizef& size); Node* setSize(const Float& Width, const Float& Height); virtual const Sizef& getSize() const; const Sizef& getPixelsSize() const; Node* setVisible(const bool& visible, bool emitEventNotification = true); Node* setChildrenVisibility(bool visible, bool emitEventNotification = true); bool isVisible() const; bool hasVisibility() const; Node* setEnabled(const bool& enabled); bool isEnabled() const; bool isDisabled() const; Node* getParent() const; Node* setParent(Node* parent); virtual void close(); virtual void draw(); virtual void update(const Time& time); virtual void scheduledUpdate(const Time& time); Node* getNextNode() const; Node* getPrevNode() const; Node* getNextNodeLoop() const; Node* setData(const UintPtr& data); const UintPtr& getData() const; Node* setBlendMode(const BlendMode& blend); const BlendMode& getBlendMode() const; Node* toFront(); Node* toBack(); void toPosition(const Uint32& position); const Uint32& getNodeFlags() const; void setNodeFlags(const Uint32& flags); bool isSceneNode() const; bool isUISceneNode() const; bool isUINode() const; bool isWidget() const; bool isWindow() const; bool isLayout() const; bool isClipped() const; bool isRotated() const; bool isScaled() const; bool isFrameBuffer() const; bool isMouseOver() const; bool isMouseOverMeOrChildren() const; bool isMeOrParentTreeVisible() const; bool isMeOrParentTreeRotated() const; bool isMeOrParentTreeScaled() const; bool isMeOrParentTreeScaledOrRotated() const; bool isMeOrParentTreeScaledOrRotatedOrFrameBuffer() const; Uint32 addEventListener(const Uint32& eventType, const EventCallback& callback); Uint32 on(const Uint32& eventType, const EventCallback& callback); Uint32 onClick(const std::function<void(const MouseEvent*)>& callback, const MouseButton& button = MouseButton::EE_BUTTON_LEFT); Uint32 onDoubleClick(const std::function<void(const MouseEvent*)>& callback, const MouseButton& button = MouseButton::EE_BUTTON_LEFT); void removeEventsOfType(const Uint32& eventType); void removeEventListener(const Uint32& callbackId); void removeEventListener(const std::vector<Uint32>& callbacksIds); void clearEventListener(); Node* getFirstChild() const; Node* getLastChild() const; const Polygon2f& getWorldPolygon(); const Rectf& getWorldBounds(); bool isParentOf(const Node* node) const; void sendEvent(const Event* Event); void sendMouseEvent(const Uint32& Event, const Vector2i& position, const Uint32& flags); void sendCommonEvent(const Uint32& Event); void sendTextEvent(const Uint32& event, const std::string& text); void closeAllChildren(); const std::string& getId() const; virtual Node* setId(const std::string& id); const String::HashType& getIdHash() const; Node* find(const std::string& id) const; Node* hasChild(const std::string& id) const; template <typename T> T* find(const std::string& id) const; template <typename T> T* bind(const std::string& id, T*& node); template <typename T> T* asType(); template <typename T> const T* asConstType() const; Node* findByType(const Uint32& type) const; template <typename T> T* findByType(const Uint32& type) const; template <typename T> T* bindByType(const Uint32& type, T*& node); std::vector<Node*> findAllByType(const Uint32& type) const; template <typename T> std::vector<T*> findAllByType(const Uint32& type) const; bool inNodeTree(Node* node) const; bool isReverseDraw() const; void setReverseDraw(bool reverseDraw); void invalidateDraw(); virtual void setRotation(float angle); void setRotation(const Float& angle, const OriginPoint& center); const OriginPoint& getRotationOriginPoint() const; void setRotationOriginPoint(const OriginPoint& center); void setRotationOriginPointPixels(const OriginPoint& center); void setRotationOriginPointX(const std::string& xEq); void setRotationOriginPointY(const std::string& yEq); Vector2f getRotationCenter() const; void setScale(const Float& scale); virtual void setScale(const Vector2f& scale); void setScale(const Vector2f& scale, const OriginPoint& center); void setScale(const Float& scale, const OriginPoint& center); const OriginPoint& getScaleOriginPoint() const; void setScaleOriginPoint(const OriginPoint& center); void setScaleOriginPointPixels(const OriginPoint& center); void setScaleOriginPointX(const std::string& xEq); void setScaleOriginPointY(const std::string& yEq); Vector2f getScaleCenter() const; virtual void setScale(float factorX, float factorY); virtual void setScaleOrigin(float x, float y); virtual void setRotationOrigin(float x, float y); const Float& getAlpha() const; virtual void setAlpha(const Float& alpha); virtual void setChildrenAlpha(const Float& alpha); ActionManager* getActionManager() const; Node* runAction(Action* action); bool removeAction(Action* action); bool removeActions(const std::vector<Action*>& actions); bool removeActionsByTag(const Action::UniqueID& tag); std::vector<Action*> getActions(); std::vector<Action*> getActionsByTag(const Action::UniqueID& tag); void clearActions(); Transform getLocalTransform() const; Transform getGlobalTransform() const; Transform getNodeToWorldTransform() const; Transform getWorldToNodeTransform() const; Vector2f convertToNodeSpace(const Vector2f& worldPoint) const; Vector2f convertToWorldSpace(const Vector2f& nodePoint) const; Rectf getLocalBounds() const; bool hasFocus() const; bool hasFocusWithin() const; virtual Node* setFocus(NodeFocusReason reason = NodeFocusReason::Unknown); Node* getFirstWidget() const; Node* getParentWidget() const; void enableReportSizeChangeToChildren(); void disableReportSizeChangeToChildren(); bool reportSizeChangeToChildren() const; Node* centerHorizontal(); Node* centerVertical(); Node* center(); Node* clipEnable(); Node* clipDisable(); void writeNodeFlag(const Uint32& Flag, const Uint32& Val); SceneNode* getSceneNode() const; EventDispatcher* getEventDispatcher() const; virtual bool isDrawInvalidator() const; bool invalidated() const; virtual void invalidate(Node* invalidator); Uint32 getChildCount() const; Uint32 getChildOfTypeCount(const Uint32& type) const; Node* getChildAt(Uint32 index) const; Uint32 getNodeIndex() const; Uint32 getNodeOfTypeIndex() const; void runOnMainThread(Actions::Runnable::RunnableFunc runnable, const Time& delay = Seconds(0), const Action::UniqueID& uniqueIdentifier = 0); bool ensureMainThread(Actions::Runnable::RunnableFunc runnable, const Action::UniqueID& uniqueIdentifier = 0); void setTimeout(Actions::Runnable::RunnableFunc runnable, const Time& delay = Seconds(0), const Action::UniqueID& uniqueIdentifier = 0); void setInterval(Actions::Runnable::RunnableFunc runnable, const Time& interval, const Action::UniqueID& uniqueIdentifier = 0); void debounce(Actions::Runnable::RunnableFunc runnable, const Time& delay, const Action::UniqueID& uniqueIdentifier); bool isChild(Node* child) const; bool inParentTreeOf(Node* child) const; bool inParentTreeOfType(Uint32 type) const; Node* getParentOfType(Uint32 type) const; void setLoadingState(bool loading); bool isLoadingState() const; virtual void onIdChange(); bool isClosing() const; bool isClosingChildren() const; virtual Node* overFind(const Vector2f& Point); void detach(); void forEachNode(std::function<void(Node*)> func); void forEachChild(std::function<void(Node*)> func); virtual void nodeDraw(); Uint32 forceKeyDown(const KeyEvent& event); Uint32 foceKeyUp(const KeyEvent& event); Uint32 forceTextInput(const TextInputEvent& Event); const Vector2f& getScreenPos() const; Rectf getScreenRect() const; bool hasEventsOfType(const Uint32& eventType) const; };
Inherited Members¶
public: // methods virtual void setPosition(const Vector2f& position); virtual void setRotation(float angle); virtual void setScale(float factorX, float factorY); virtual void setScale(const Vector2f& factors); virtual void setScaleOrigin(float x, float y); virtual void setScaleOrigin(const Vector2f& origin); virtual void setRotationOrigin(float x, float y); virtual void setRotationOrigin(const Vector2f& origin); virtual const Vector2f& getRotationOrigin() const; virtual const Vector2f& getPosition() const; virtual const float& getRotation() const; virtual const Vector2f& getScale() const; virtual const Vector2f& getScaleOrigin() const; void move(float offsetX, float offsetY); void move(const Vector2f& offset); void rotate(float angle); void scale(float factorX, float factorY); void scale(const Vector2f& factor); const Transform& getTransform() const; const Transform& getInverseTransform() const;
Detailed Documentation¶
Core node class for scene graph management.
Node is the fundamental building block for the scene graph system. It provides hierarchical organization with parent-child relationships, transformation support (position, rotation, scale), event handling, and rendering capabilities.
Nodes can be used for general scene management or as base classes for specialized nodes like SceneNode and UISceneNode. The class supports both simple scene composition and complex UI hierarchies.
Key features:
Hierarchical parent-child relationships
2D transformations (position, rotation, scale)
Event system with callbacks
Action system for animations and timed operations
Coordinate space conversion
Visibility and enabled state management
Drawing with optional clipping and reverse order
Dirty flag system for efficient updates
See also:
UISceneNode
UIWidget
Construction¶
virtual ~Node()
Destructor.
Cleans up the node and its children, removes it from parent, and handles cleanup of actions, event listeners, and focus state.
Methods¶
static Node* New()
Creates a new Node instance.
This factory method creates a new Node with default values. Direct instantiation of Node is uncommon; typically derived classes like SceneNode or UIWidget are used.
Returns:
Pointer to the newly created Node instance.
virtual void worldToNodeTranslation(Vector2f& position) const
Transforms a world position to node-local position.
Converts a world coordinate position to this node’s local coordinate space by subtracting the positions of all parent nodes up to the root.
Parameters:
position |
Reference to the position to transform (modified in place). |
virtual void nodeToWorldTranslation(Vector2f& position) const
Transforms a node-local position to world position.
Converts a node-local coordinate position to world coordinate space by adding the positions of all parent nodes.
Parameters:
position |
Reference to the position to transform (modified in place). |
virtual void worldToNode(Vector2i& pos) const
Converts world integer coordinates to node-local coordinates.
Transforms a world position (with integer coordinates) to this node’s local coordinate space.
Parameters:
pos |
Reference to the integer position to transform (modified in place). |
virtual void nodeToWorld(Vector2i& pos) const
Converts node-local integer coordinates to world coordinates.
Transforms a node-local position (with integer coordinates) to world coordinate space.
Parameters:
pos |
Reference to the integer position to transform (modified in place). |
virtual void worldToNode(Vector2f& pos) const
Converts world floating-point coordinates to node-local coordinates.
Transforms a world position (with floating-point coordinates) to this node’s local coordinate space.
Parameters:
pos |
Reference to the floating-point position to transform (modified in place). |
virtual void nodeToWorld(Vector2f& pos) const
Converts node-local floating-point coordinates to world coordinates.
Transforms a node-local position (with floating-point coordinates) to world coordinate space.
Parameters:
pos |
Reference to the floating-point position to transform (modified in place). |
virtual Uint32 getType() const
Gets the node type identifier.
Returns a unique type identifier for this node class. Derived classes should override this to return their specific type constant.
Returns:
The node type as a Uint32.
virtual bool isType(const Uint32& type) const
Checks if the node is of a specific type.
Determines whether this node is of the specified type or derived from it.
Parameters:
type |
The type identifier to check. |
Returns:
True if the node is of the specified type, false otherwise.
void messagePost(const NodeMessage* Msg)
Posts a message to this node and its ancestors.
Sends a node message up the parent chain until a node handles it. Messages are used for custom communication between nodes.
Parameters:
Msg |
Pointer to the NodeMessage to post. |
virtual void setPosition(const Vector2f& Pos)
Sets the node position in density-independent pixels (dp).
Sets the position of the node. The position is relative to the parent node’s coordinate system. Setting a new position marks the node as dirty and triggers layout updates.
Parameters:
Pos |
The new position. |
virtual Node* setPosition(const Float& x, const Float& y)
Sets the node position using separate coordinates.
Convenience method to set the X and Y coordinates individually.
Parameters:
x |
The X coordinate. |
y |
The Y coordinate. |
Returns:
Pointer to this node for method chaining.
virtual Node* setSize(const Sizef& size)
Sets the node size in density-independent pixels (dp).
Sets the size of the node. The size will be validated against minimum/maximum constraints if applicable.
Parameters:
size |
The new size. |
Returns:
Pointer to this node for method chaining.
Node* setSize(const Float& Width, const Float& Height)
Sets the node size using separate width and height values.
Convenience method to set width and height individually.
Parameters:
Width |
The width in dp. |
Height |
The height in dp. |
Returns:
Pointer to this node for method chaining.
virtual const Sizef& getSize() const
Gets the node size in density-independent pixels (dp).
Returns the current size of the node. This value may differ from the pixel size if scaling is applied.
Returns:
The size as a Sizef.
const Sizef& getPixelsSize() const
Gets the node size in actual screen pixels.
Returns the current size of the node in raw pixel units, accounting for any scaling factors.
Returns:
The pixel size as a Sizef.
Node* setVisible(const bool& visible, bool emitEventNotification = true)
Sets the visibility of the node.
Controls whether the node is rendered. Invisible nodes and their children are not drawn and do not receive mouse events.
Parameters:
visible |
True to make the node visible, false to hide it. |
emitEventNotification |
If true, emits a visibility change event. |
Returns:
Pointer to this node for method chaining.
Node* setChildrenVisibility(bool visible, bool emitEventNotification = true)
Sets visibility for all children recursively.
Changes the visibility state of this node and all its descendants.
Parameters:
visible |
The visibility state to set. |
emitEventNotification |
If true, emits visibility change events. |
Returns:
Pointer to this node for method chaining.
bool isVisible() const
Checks if the node is visible.
Returns the current visibility state of this node only, not considering parent visibility.
Returns:
True if the node is visible, false otherwise.
bool hasVisibility() const
Checks if the node and all its parents are visible.
Traverses up the parent chain to verify that this node and all ancestors are visible. Useful for determining if the node will actually be rendered.
Returns:
True if the node and all parents are visible, false otherwise.
Node* setEnabled(const bool& enabled)
Enables or disables the node.
Disabled nodes do not receive input events and are typically rendered with a disabled appearance.
Parameters:
enabled |
True to enable the node, false to disable. |
Returns:
Pointer to this node for method chaining.
bool isEnabled() const
Checks if the node is enabled.
Returns:
True if the node is enabled, false if disabled.
bool isDisabled() const
Checks if the node is disabled.
Convenience method equivalent to !isEnabled().
Returns:
True if the node is disabled, false otherwise.
Node* getParent() const
Gets the parent node.
Returns the direct parent of this node in the scene graph, or nullptr if the node has no parent.
Returns:
Pointer to the parent node or nullptr.
Node* setParent(Node* parent)
Sets the parent node.
Re-parents this node to a new parent. The node is automatically removed from its current parent if any.
Parameters:
parent |
The new parent node. |
Returns:
Pointer to this node for method chaining.
virtual void close()
Closes the node.
Marks the node for closure. The node will be removed from the scene during the next update cycle. This is the safe way to remove nodes as it prevents iterator invalidation issues.
virtual void draw()
Draws the node.
Virtual method that derived classes should override to implement custom rendering. The default implementation does nothing. This is called during the render cycle after the transformation matrix is set up.
virtual void update(const Time& time)
Updates the node.
Called once per frame to update the node’s state. The default implementation recursively updates all children. Derived classes should call the base implementation to maintain child updates.
Parameters:
time |
The time elapsed since the last frame. |
virtual void scheduledUpdate(const Time& time)
Performs scheduled updates for nodes with update subscriptions.
Called by the scene manager for nodes that have subscribed to scheduled updates. Override to implement time-based update logic for this node.
Parameters:
time |
The time elapsed since the last frame. |
Node* getNextNode() const
Gets the next sibling node in the parent’s child list.
Returns the node that comes after this one in the parent’s linked list of children, or nullptr if this is the last child.
Returns:
Pointer to the next sibling node or nullptr.
Node* getPrevNode() const
Gets the previous sibling node in the parent’s child list.
Returns the node that comes before this one in the parent’s linked list of children, or nullptr if this is the first child.
Returns:
Pointer to the previous sibling node or nullptr.
Node* getNextNodeLoop() const
Gets the next sibling node, wrapping to first if at end.
Returns the next sibling node, or if this is the last child, returns the parent’s first child (creating a circular traversal).
Returns:
Pointer to the next node in the loop.
Node* setData(const UintPtr& data)
Attaches arbitrary user data to this node.
Sets a user data pointer that can be used to associate custom data with this node. The data is not managed by the node and must be cleaned up by the user.
Parameters:
data |
The user data pointer to store. |
Returns:
Pointer to this node for method chaining.
const UintPtr& getData() const
Gets the user data previously set with setData().
Returns:
The stored user data pointer.
Node* setBlendMode(const BlendMode& blend)
Sets the blend mode for this node.
Controls how this node’s colors blend with the background when rendered. Common blend modes include Alpha, Add, Multiply, etc.
Parameters:
blend |
The blend mode to use. |
Returns:
Pointer to this node for method chaining.
const BlendMode& getBlendMode() const
Gets the current blend mode.
Returns:
The current blend mode.
Node* toFront()
Moves this node to the front of its parent’s child list.
Changes the rendering order so this node is drawn after all its siblings. This affects the visual stacking order (nodes drawn later appear on top).
Returns:
Pointer to this node for method chaining.
Node* toBack()
Moves this node to the back of its parent’s child list.
Changes the rendering order so this node is drawn before all its siblings. This affects the visual stacking order (nodes drawn earlier appear behind).
Returns:
Pointer to this node for method chaining.
void toPosition(const Uint32& position)
Moves this node to a specific position in the parent’s child list.
Changes the rendering order by placing this node at the specified index among its siblings.
Parameters:
position |
The zero-based index position in the parent’s child list. |
const Uint32& getNodeFlags() const
Gets the current node flags.
Returns the bitmask of flags that control various node behaviors and states.
Returns:
The flags as a Uint32 bitmask.
void setNodeFlags(const Uint32& flags)
Sets the node flags directly.
Use with caution - this replaces all flags and may cause unexpected behavior. Prefer specific flag manipulation methods when available.
Parameters:
flags |
The new flags bitmask. |
bool isSceneNode() const
Checks if this node is a SceneNode.
SceneNode is the base class for nodes that handle rendering and scene management.
Returns:
True if this node is a SceneNode, false otherwise.
bool isUISceneNode() const
Checks if this node is a UISceneNode.
UISceneNode is the root node for UI rendering with CSS styling support.
Returns:
True if this node is a UISceneNode, false otherwise.
bool isUINode() const
Checks if this node is a UINode.
UINode is the base class for UI elements with theming and layout support.
Returns:
True if this node is a UINode, false otherwise.
bool isWidget() const
Checks if this node is a UIWidget.
UIWidget is the base class for interactive UI elements with CSS support.
Returns:
True if this node is a UIWidget, false otherwise.
bool isWindow() const
Checks if this node is a Window.
Window nodes represent top-level application windows.
Returns:
True if this node is a Window, false otherwise.
bool isLayout() const
Checks if this node is a Layout.
Layout nodes are specialized containers that manage the positioning of their children according to layout rules.
Returns:
True if this node is a Layout, false otherwise.
bool isClipped() const
Checks if clipping is enabled for this node.
When clipping is enabled, node content is restricted to the node’s bounds.
Returns:
True if clipping is enabled, false otherwise.
bool isRotated() const
Checks if this node has rotation applied.
Returns:
True if the node’s rotation is non-zero, false otherwise.
bool isScaled() const
Checks if this node has scaling applied.
Returns:
True if the node’s scale is not (1,1), false otherwise.
bool isFrameBuffer() const
Checks if this node uses a frame buffer.
Frame buffer nodes render to an off-screen texture first.
Returns:
True if using frame buffer rendering, false otherwise.
bool isMouseOver() const
Checks if the mouse is currently over this node.
Returns:
True if the mouse cursor is over this node, false otherwise.
bool isMouseOverMeOrChildren() const
Checks if the mouse is over this node or any of its children.
Returns:
True if the mouse is over this node or any descendant, false otherwise.
bool isMeOrParentTreeVisible() const
Checks if this node and all its parents are visible in the tree.
Similar to hasVisibility() but optimized for tree traversal.
Returns:
True if this node and all ancestors are visible, false otherwise.
bool isMeOrParentTreeRotated() const
Checks if this node or any parent has rotation.
Returns:
True if this node or any ancestor is rotated, false otherwise.
bool isMeOrParentTreeScaled() const
Checks if this node or any parent has scaling.
Returns:
True if this node or any ancestor is scaled, false otherwise.
bool isMeOrParentTreeScaledOrRotated() const
Checks if this node or any parent has scaling or rotation.
Returns:
True if this node or any ancestor is scaled or rotated, false otherwise.
bool isMeOrParentTreeScaledOrRotatedOrFrameBuffer() const
Checks if this node or any parent has scaling, rotation, or frame buffer.
This is used to determine if special clipping planes are needed.
Returns:
True if this node or any ancestor has any of these transforms, false otherwise.
Uint32 addEventListener(const Uint32& eventType, const EventCallback& callback)
Adds an event listener for a specific event type.
Registers a callback function to be invoked when the specified event occurs. Returns a unique ID that can be used to remove the listener later.
Parameters:
eventType |
The event type constant (e.g., Event::MouseClick). |
callback |
The function to call when the event occurs. |
Returns:
A unique callback identifier.
Uint32 on(const Uint32& eventType, const EventCallback& callback)
Adds an event listener (alias for addEventListener).
Parameters:
eventType |
The event type constant. |
callback |
The function to call when the event occurs. |
Returns:
A unique callback identifier.
Uint32 onClick(const std::function<void(const MouseEvent*)>& callback, const MouseButton& button = MouseButton::EE_BUTTON_LEFT)
Adds a mouse click event listener.
Convenience method to listen for mouse click events, optionally filtered by mouse button.
Parameters:
callback |
The function to call on mouse click. |
button |
The mouse button to filter for (default: left button). |
Returns:
A unique callback identifier.
Uint32 onDoubleClick(const std::function<void(const MouseEvent*)>& callback, const MouseButton& button = MouseButton::EE_BUTTON_LEFT)
Adds a mouse double-click event listener.
Convenience method to listen for mouse double-click events.
Parameters:
callback |
The function to call on double click. |
button |
The mouse button to filter for (default: left button). |
Returns:
A unique callback identifier.
void removeEventsOfType(const Uint32& eventType)
Removes all event listeners of a specific type.
Parameters:
eventType |
The event type to remove listeners for. |
void removeEventListener(const Uint32& callbackId)
Removes a specific event listener by its callback ID.
Parameters:
callbackId |
The ID returned by addEventListener or on(). |
void removeEventListener(const std::vector<Uint32>& callbacksIds)
Removes multiple event listeners by their callback IDs.
Parameters:
callbacksIds |
Vector of callback IDs to remove. |
void clearEventListener()
Removes all event listeners from this node.
Clears the entire event listener registry.
Node* getFirstChild() const
Gets the first child node.
Returns:
Pointer to the first child or nullptr if no children exist.
Node* getLastChild() const
Gets the last child node.
Returns:
Pointer to the last child or nullptr if no children exist.
const Polygon2f& getWorldPolygon()
Gets the world polygon of this node.
Returns the axis-aligned bounding polygon in world coordinates, accounting for all transformations (position, rotation, scale, parent transforms). The polygon is cached and only recalculated when dirty.
Returns:
Const reference to the Polygon2f representing world bounds.
const Rectf& getWorldBounds()
Gets the world bounding rectangle.
Returns the axis-aligned bounding box in world coordinates. This is derived from the world polygon and is also cached.
Returns:
Const reference to the Rectf representing world bounds.
bool isParentOf(const Node* node) const
Checks if a node is a descendant of this node.
Determines whether the specified node is in this node’s subtree.
Parameters:
node |
The node to check. |
Returns:
True if node is a child or grandchild, false otherwise.
void sendEvent(const Event* Event)
Sends an event to this node for handling.
Dispatches the event to all registered listeners for the event type. The event is processed synchronously in the calling thread.
Parameters:
Pointer to the event to send. |
void sendMouseEvent(const Uint32& Event, const Vector2i& position, const Uint32& flags)
Sends a mouse event to this node.
Creates and sends a MouseEvent with the specified parameters.
Parameters:
The mouse event type (e.g., Event::MouseClick). |
|
position |
The mouse position in pixels. |
flags |
The mouse event flags (button states, modifiers). |
void sendCommonEvent(const Uint32& Event)
Sends a common event to this node.
Creates and sends an Event with the specified event type.
Parameters:
The event type. |
void sendTextEvent(const Uint32& event, const std::string& text)
Sends a text event to this node.
Creates and sends a TextEvent with the specified text content.
Parameters:
event |
The event type (typically text-related). |
text |
The text string to send. |
void closeAllChildren()
Closes all children recursively.
Marks all descendant nodes for closure. The nodes will be removed during the next update cycle.
const std::string& getId() const
Gets the node’s identifier string.
Returns the unique ID string set with setId(). An empty string means no ID is set.
Returns:
The node ID as a const string reference.
virtual Node* setId(const std::string& id)
Sets the node’s identifier string.
Assigns a unique ID to this node. The ID can be used for CSS selectors and for finding the node with find(). Calling setId() also updates the cached hash value and triggers onIdChange().
Parameters:
id |
The ID string to set. |
Returns:
Pointer to this node for method chaining.
const String::HashType& getIdHash() const
Gets the precomputed hash of the node ID.
Returns the cached hash of the ID string for efficient lookups.
Returns:
The ID hash value.
Node* find(const std::string& id) const
Finds a descendant node by its ID string.
Searches the subtree rooted at this node for a node with the specified ID. The search is depth-first and stops at the first match.
Parameters:
id |
The ID string to search for. |
Returns:
Pointer to the matching node or nullptr if not found.
Node* hasChild(const std::string& id) const
Checks if this node has a direct child with the specified ID.
Only searches among immediate children, not the full subtree.
Parameters:
id |
The ID string to search for. |
Returns:
Pointer to the child node or nullptr if not found.
template <typename T> T* find(const std::string& id) const
Template version of find() with type casting.
Finds a descendant node by ID and casts it to the specified type. Returns nullptr if not found or if the cast would fail.
Parameters:
T |
The type to cast the found node to. |
id |
The ID string to search for. |
Returns:
Pointer to the node cast to T* or nullptr.
template <typename T> T* bind(const std::string& id, T*& node)
Template version of hasChild() with type casting.
Finds a direct child by ID and casts it to the specified type.
Parameters:
T |
The type to cast the found child to. |
id |
The ID string to search for. |
node |
Output parameter that receives the found node pointer. |
Returns:
Pointer to the node cast to T* or nullptr.
template <typename T> T* asType()
Casts this node to a different type without checking.
Dangerous - use only when you are certain of the actual type.
Parameters:
T |
The type to cast to. |
Returns:
Pointer to this node as T*.
template <typename T> const T* asConstType() const
Const version of asType().
Parameters:
T |
The type to cast to. |
Returns:
Const pointer to this node as const T*.
Node* findByType(const Uint32& type) const
Finds a descendant node by type.
Searches the subtree for the first node of the specified type. The search is depth-first and checks node types using isType().
Parameters:
type |
The node type constant to search for. |
Returns:
Pointer to the first matching node or nullptr.
template <typename T> T* findByType(const Uint32& type) const
Template version of findByType() with type casting.
Finds a descendant node by type and casts it to the specified template type.
Parameters:
T |
The type to cast to. |
type |
The node type constant to search for. |
Returns:
Pointer to the node cast to T* or nullptr.
template <typename T> T* bindByType(const Uint32& type, T*& node)
Template helper for findByType() with output parameter.
Finds a descendant node by type and stores the result in the output parameter.
Parameters:
T |
The type to cast to. |
type |
The node type constant to search for. |
node |
Output parameter that receives the found node pointer. |
Returns:
Pointer to the found node cast to T* or nullptr.
std::vector<Node*> findAllByType(const Uint32& type) const
Finds all descendant nodes of a specific type.
Searches the entire subtree and collects all nodes matching the specified type.
Parameters:
type |
The node type constant to search for. |
Returns:
Vector of pointers to all matching nodes (may be empty).
template <typename T> std::vector<T*> findAllByType(const Uint32& type) const
Template version of findAllByType() with type casting.
Finds all descendant nodes of a type and casts them to the specified template type.
Parameters:
T |
The type to cast each node to. |
type |
The node type constant to search for. |
Returns:
Vector of pointers to nodes cast to T* (may be empty).
bool inNodeTree(Node* node) const
Checks if a node is in this node’s tree.
Determines whether the specified node is this node itself or any descendant.
Parameters:
node |
The node to check. |
Returns:
True if the node is in this tree, false otherwise.
bool isReverseDraw() const
Checks if this node draws in reverse order.
When reverse draw is enabled, children are drawn from last to first, causing the last child to appear on top.
Returns:
True if reverse drawing is enabled, false otherwise.
void setReverseDraw(bool reverseDraw)
Enables or disables reverse drawing order.
Controls whether children are drawn in normal order (first to last) or reverse order (last to first).
Parameters:
reverseDraw |
True to draw children in reverse order. |
void invalidateDraw()
Invalidates this node’s draw state.
Marks the node as needing to be redrawn. This triggers a redraw in the next frame. The invalidation is propagated to the draw invalidator node.
virtual void setRotation(float angle)
Sets the rotation angle in degrees.
Sets the node’s rotation around its rotation origin point. The rotation is applied in world coordinates after scaling.
Parameters:
angle |
The rotation angle in degrees. |
void setRotation(const Float& angle, const OriginPoint& center)
Sets the rotation angle and origin point.
Sets both the rotation angle and the point around which rotation occurs.
Parameters:
angle |
The rotation angle in degrees. |
center |
The rotation origin point in dp. |
const OriginPoint& getRotationOriginPoint() const
Gets the current rotation origin point.
Returns the point around which rotation is applied, in dp units.
Returns:
Const reference to the rotation origin point.
void setRotationOriginPoint(const OriginPoint& center)
Sets the rotation origin point in dp.
Defines the point around which rotation occurs, using dp units.
Parameters:
center |
The rotation origin point in dp. |
void setRotationOriginPointPixels(const OriginPoint& center)
Sets the rotation origin point in pixels.
Like setRotationOriginPoint but uses pixel units directly without dp conversion.
Parameters:
center |
The rotation origin point in pixels. |
void setRotationOriginPointX(const std::string& xEq)
Sets the X coordinate of the rotation origin using a CSS-like expression.
Allows dynamic origin specification with expressions like “50%” or “10px”.
Parameters:
xEq |
The X coordinate expression string. |
void setRotationOriginPointY(const std::string& yEq)
Sets the Y coordinate of the rotation origin using a CSS-like expression.
Allows dynamic origin specification with expressions like “50%” or “10px”.
Parameters:
yEq |
The Y coordinate expression string. |
Vector2f getRotationCenter() const
Gets the actual rotation center in screen coordinates.
Calculates and returns the world-space point around which rotation occurs, based on the origin point setting and current size.
Returns:
The rotation center as a Vector2f in dp.
void setScale(const Float& scale)
Sets uniform scaling factor.
Sets the same scale factor for both X and Y axes. Scale of 1.0 means no scaling, values > 1 enlarge, values < 1 shrink.
Parameters:
scale |
The uniform scale factor. |
virtual void setScale(const Vector2f& scale)
Sets scaling with separate factors for X and Y.
Parameters:
scale |
The scale vector (x, y factors). |
void setScale(const Vector2f& scale, const OriginPoint& center)
Sets scaling with origin point.
Sets the scale factors and the origin point around which scaling occurs.
Parameters:
scale |
The scale vector (x, y factors). |
center |
The scaling origin point in dp. |
void setScale(const Float& scale, const OriginPoint& center)
Sets uniform scaling with origin point.
Sets uniform scaling and the origin point around which scaling occurs.
Parameters:
scale |
The uniform scale factor. |
center |
The scaling origin point in dp. |
const OriginPoint& getScaleOriginPoint() const
Gets the current scale origin point.
Returns the point around which scaling is applied, in dp units.
Returns:
Const reference to the scale origin point.
void setScaleOriginPoint(const OriginPoint& center)
Sets the scale origin point in dp.
Defines the point around which scaling occurs.
Parameters:
center |
The scale origin point in dp. |
void setScaleOriginPointPixels(const OriginPoint& center)
Sets the scale origin point in pixels.
Like setScaleOriginPoint but uses pixel units directly without dp conversion.
Parameters:
center |
The scale origin point in pixels. |
void setScaleOriginPointX(const std::string& xEq)
Sets the X coordinate of the scale origin using a CSS-like expression.
Allows dynamic origin specification with expressions like “50%” or “10px”.
Parameters:
xEq |
The X coordinate expression string. |
void setScaleOriginPointY(const std::string& yEq)
Sets the Y coordinate of the scale origin using a CSS-like expression.
Allows dynamic origin specification with expressions like “50%” or “10px”.
Parameters:
yEq |
The Y coordinate expression string. |
Vector2f getScaleCenter() const
Gets the actual scale center in screen coordinates.
Calculates and returns the world-space point around which scaling occurs, based on the origin point setting and current size.
Returns:
The scale center as a Vector2f in dp.
virtual void setScale(float factorX, float factorY)
Sets non-uniform scaling with raw float factors.
Virtual method that derived classes can override to add custom scaling behavior.
Parameters:
factorX |
The X scale factor. |
factorY |
The Y scale factor. |
virtual void setScaleOrigin(float x, float y)
Sets the scale origin with raw coordinates.
Virtual method that sets the point around which scaling occurs using raw float coordinates.
Parameters:
x |
The X coordinate of the scale origin. |
y |
The Y coordinate of the scale origin. |
virtual void setRotationOrigin(float x, float y)
Sets the rotation origin with raw coordinates.
Virtual method that sets the point around which rotation occurs using raw float coordinates.
Parameters:
x |
The X coordinate of the rotation origin. |
y |
The Y coordinate of the rotation origin. |
const Float& getAlpha() const
Gets the current alpha (transparency) value.
Returns the alpha value that affects this node’s opacity. Range is typically 0-255 where 0 is fully transparent and 255 is fully opaque.
Returns:
The alpha value as a Float (typically 0-255).
virtual void setAlpha(const Float& alpha)
Sets the alpha (transparency) for this node.
Controls the opacity of this node. Values typically range from 0 (transparent) to 255 (opaque). This affects both the node and its children.
Parameters:
alpha |
The alpha value to set. |
virtual void setChildrenAlpha(const Float& alpha)
Sets alpha for this node and all children recursively.
Convenience method to set uniform alpha across the entire subtree.
Parameters:
alpha |
The alpha value to set for all nodes. |
ActionManager* getActionManager() const
Gets the action manager associated with this node.
Returns the ActionManager that controls actions (animations, timed callbacks) for this node. The action manager is obtained from the scene node.
Returns:
Pointer to the ActionManager.
Node* runAction(Action* action)
Runs an action on this node.
Starts an action (animation, delay, callback, etc.) that will be updated automatically. The action will be owned by the action manager.
Parameters:
action |
Pointer to the Action to run. |
Returns:
Pointer to this node for method chaining.
bool removeAction(Action* action)
Removes a specific action from this node.
Stops and removes the specified action if it is running on this node.
Parameters:
action |
Pointer to the action to remove. |
Returns:
True if the action was found and removed, false otherwise.
bool removeActions(const std::vector<Action*>& actions)
Removes multiple actions from this node.
Stops and removes all actions in the provided vector.
Parameters:
actions |
Vector of action pointers to remove. |
Returns:
True if any actions were removed, false otherwise.
bool removeActionsByTag(const Action::UniqueID& tag)
Removes all actions with a specific tag from this node.
Useful for stopping a group of related actions identified by a common tag.
Parameters:
tag |
The unique tag identifier. |
Returns:
True if any actions were removed, false otherwise.
std::vector<Action*> getActions()
Gets all actions currently running on this node.
Returns:
Vector of pointers to all active actions.
std::vector<Action*> getActionsByTag(const Action::UniqueID& tag)
Gets all actions with a specific tag.
Parameters:
tag |
The tag to search for. |
Returns:
Vector of pointers to matching actions (may be empty).
void clearActions()
Removes all actions from this node.
Stops and clears every action currently running on this node.
Transform getLocalTransform() const
Gets the local transformation matrix.
Returns the transformation matrix representing this node’s local transform (position, rotation, scale) without parent influences.
Returns:
The local Transform matrix.
Transform getGlobalTransform() const
Gets the global transformation matrix.
Returns the complete transformation matrix from this node’s local space to world space, including all parent transformations.
Returns:
The global Transform matrix.
Transform getNodeToWorldTransform() const
Gets the node-to-world transformation matrix.
Alias for getGlobalTransform().
Returns:
The node-to-world Transform matrix.
Transform getWorldToNodeTransform() const
Gets the world-to-node transformation matrix.
Returns the inverse of the node-to-world transform, useful for converting world coordinates to this node’s local space.
Returns:
The world-to-node Transform matrix.
Vector2f convertToNodeSpace(const Vector2f& worldPoint) const
Converts a world point to node-local coordinates.
Transforms a point from world space to this node’s local space using the transformation matrices.
Parameters:
worldPoint |
The point in world coordinates. |
Returns:
The point in node-local coordinates.
Vector2f convertToWorldSpace(const Vector2f& nodePoint) const
Converts a node-local point to world coordinates.
Transforms a point from this node’s local space to world space.
Parameters:
nodePoint |
The point in node-local coordinates. |
Returns:
The point in world coordinates.
Rectf getLocalBounds() const
Gets the node’s local bounding rectangle.
Returns the axis-aligned bounding box in the node’s local coordinate space (from origin to size). This is the untransformed bounds.
Returns:
Rectf representing local bounds (0,0 to width,height).
bool hasFocus() const
Checks if this node currently has input focus.
Focus means this node receives keyboard and other input events.
Returns:
True if this node has focus, false otherwise.
bool hasFocusWithin() const
Checks if this node or any descendant has focus.
Returns:
True if this node or any child has focus, false otherwise.
virtual Node* setFocus(NodeFocusReason reason = NodeFocusReason::Unknown)
Requests input focus for this node.
Attempts to give this node keyboard focus. Derived classes may override to implement custom focus behavior.
Parameters:
reason |
The reason for the focus request. |
Returns:
Pointer to this node if focus was granted, nullptr otherwise.
Node* getFirstWidget() const
Gets the first widget child.
Searches among direct children and returns the first one that is a UIWidget.
Returns:
Pointer to the first child widget or nullptr if none found.
Node* getParentWidget() const
Gets the nearest widget ancestor.
Traverses up the parent chain looking for a widget. Useful for finding a UIWidget container.
Returns:
Pointer to the parent widget or nullptr if not found.
void enableReportSizeChangeToChildren()
Enables reporting of size changes to children.
When enabled, children will receive onParentSizeChange() calls when this node’s size changes.
void disableReportSizeChangeToChildren()
Disables reporting of size changes to children.
When disabled, children will not be notified when this node’s size changes.
bool reportSizeChangeToChildren() const
Checks if size change reporting to children is enabled.
Returns:
True if size changes are reported to children, false otherwise.
Node* centerHorizontal()
Centers this node horizontally within its parent.
Adjusts the node’s X position so it is centered in the parent’s width.
Returns:
Pointer to this node for method chaining.
Node* centerVertical()
Centers this node vertically within its parent.
Adjusts the node’s Y position so it is centered in the parent’s height.
Returns:
Pointer to this node for method chaining.
Node* center()
Centers this node both horizontally and vertically.
Convenience method that calls both centerHorizontal() and centerVertical().
Returns:
Pointer to this node for method chaining.
Node* clipEnable()
Enables clipping to the node’s bounds.
When clipping is enabled, content drawn outside this node’s rectangle will be cut off.
Returns:
Pointer to this node for method chaining.
Node* clipDisable()
Disables clipping to the node’s bounds.
Content will be allowed to draw outside the node’s rectangle.
Returns:
Pointer to this node for method chaining.
void writeNodeFlag(const Uint32& Flag, const Uint32& Val)
Sets or clears a specific node flag bit.
Internal helper method for modifying individual flag bits without affecting other flags.
Parameters:
Flag |
The flag bit to modify (one of the NODE_FLAG_* constants). |
Val |
The value to set (1 to set, 0 to clear). |
SceneNode* getSceneNode() const
Gets the SceneNode that contains this node.
Traverses up the parent chain to find the nearest SceneNode ancestor.
Returns:
Pointer to the SceneNode or nullptr if not found.
EventDispatcher* getEventDispatcher() const
Gets the event dispatcher associated with this node.
Returns the EventDispatcher from the scene node, or nullptr if this node is not in a scene.
Returns:
Pointer to the EventDispatcher or nullptr.
virtual bool isDrawInvalidator() const
Checks if this node is a draw invalidator.
Draw invalidators are nodes that trigger redraws of their entire subtree when they become invalidated. The base Node class returns false; derived classes like SceneNode override this to return true.
Returns:
True if this node invalidates children on draw invalidation.
bool invalidated() const
Checks if this node has been invalidated.
Returns whether the view dirty flag is set, indicating the node needs to be redrawn.
Returns:
True if the node is invalidated, false otherwise.
virtual void invalidate(Node* invalidator)
Invalidates this node and optionally its children.
Marks this node as needing redraw. If the node is visible and has non-zero alpha, sets the view dirty flag. Derived classes may override to add custom invalidation logic.
Parameters:
invalidator |
The node that caused the invalidation (unused in base). |
Uint32 getChildCount() const
Gets the number of direct children.
Returns:
Count of immediate child nodes.
Uint32 getChildOfTypeCount(const Uint32& type) const
Counts children of a specific type.
Counts how many immediate children have the specified node type.
Parameters:
type |
The node type to count. |
Returns:
Number of children of that type.
Node* getChildAt(Uint32 index) const
Gets the child node at the specified index.
Returns the child at the given zero-based index in the linked list of children. Children are stored in the order they were added.
Parameters:
index |
Zero-based index of the child to retrieve. |
Returns:
Pointer to the child node or nullptr if index is out of range.
Uint32 getNodeIndex() const
Gets the index of this node in its parent’s child list.
Returns the zero-based position of this node among its siblings.
Returns:
The node index, or 0 if the node has no parent.
Uint32 getNodeOfTypeIndex() const
Gets the index of this node among siblings of the same type.
Returns the position of this node when counting only siblings that have the same type as this node.
Returns:
The type-based node index, or 0 if the node has no parent.
void runOnMainThread(Actions::Runnable::RunnableFunc runnable, const Time& delay = Seconds(0), const Action::UniqueID& uniqueIdentifier = 0)
Enqueues a runnable to be executed on the main thread.
Schedules the runnable function to be executed during the scene node’s update cycle, on the main thread. Useful for thread-safe operations from background threads.
Parameters:
runnable |
The function to execute. |
delay |
The time to wait before execution (default: 0). |
uniqueIdentifier |
Optional unique ID for the action. |
bool ensureMainThread(Actions::Runnable::RunnableFunc runnable, const Action::UniqueID& uniqueIdentifier = 0)
Executes runnable immediately if on main thread, otherwise queues it.
Checks if called from the main thread. If so, executes the runnable immediately. If not, queues it for execution on the main thread via runOnMainThread().
Parameters:
runnable |
The function to execute. |
uniqueIdentifier |
Optional unique ID for the action. |
Returns:
True if executed immediately, false if queued.
void setTimeout(Actions::Runnable::RunnableFunc runnable, const Time& delay = Seconds(0), const Action::UniqueID& uniqueIdentifier = 0)
Executes a runnable after a delay.
Schedules the runnable to be executed once after the specified delay.
Parameters:
runnable |
The function to execute. |
delay |
The time to wait before execution. |
uniqueIdentifier |
Optional unique ID for the action. |
void setInterval(Actions::Runnable::RunnableFunc runnable, const Time& interval, const Action::UniqueID& uniqueIdentifier = 0)
Executes a runnable repeatedly at fixed intervals.
Schedules the runnable to be executed repeatedly, with a fixed time delay between each call. The runnable will continue until cancelled.
Parameters:
runnable |
The function to execute. |
interval |
The time between executions. |
uniqueIdentifier |
Optional unique ID for the action. |
void debounce(Actions::Runnable::RunnableFunc runnable, const Time& delay, const Action::UniqueID& uniqueIdentifier)
Debounces a runnable execution.
If the debounce function is called again before the delay expires, the previous pending execution is cancelled and the timer resets. Useful for rate-limiting rapid successive calls.
Parameters:
runnable |
The function to execute after the delay. |
delay |
The debounce delay. |
uniqueIdentifier |
Unique ID used to identify and cancel previous debounced calls. |
bool isChild(Node* child) const
Checks if a node is a direct child of this node.
Parameters:
child |
The node to check. |
Returns:
True if the node is an immediate child, false otherwise.
bool inParentTreeOf(Node* child) const
Checks if a node is in this node’s parent tree.
Determines whether the specified node is an ancestor of this node.
Parameters:
child |
The node to treat as child (checking if this node is its parent). |
Returns:
True if this node is in the parent chain of the given node.
bool inParentTreeOfType(Uint32 type) const
Checks if any ancestor has a specific node type.
Traverses the parent chain looking for a node of the specified type.
Parameters:
type |
The node type to look for. |
Returns:
True if an ancestor of that type exists, false otherwise.
Node* getParentOfType(Uint32 type) const
Finds the nearest ancestor of a specific type.
Traverses up the parent chain and returns the first node matching the type.
Parameters:
type |
The node type to search for. |
Returns:
Pointer to the parent node of that type, or nullptr if not found.
void setLoadingState(bool loading)
Sets the loading state flag.
Marks the node as loading or not loading. This flag can be used to suppress certain operations during loading.
Parameters:
loading |
True to set loading state, false to clear. |
bool isLoadingState() const
Checks if the node is in loading state.
Returns:
True if the node’s loading flag is set, false otherwise.
virtual void onIdChange()
Called when the node’s ID changes.
Virtual method that can be overridden to respond to ID changes. The default implementation sends an OnIdChange event.
bool isClosing() const
Checks if the node is marked for closure.
Returns:
True if the close flag is set (node will be removed), false otherwise.
bool isClosingChildren() const
Checks if the node is in the process of closing children.
Returns:
True if the closing children flag is set, false otherwise.
virtual Node* overFind(const Vector2f& Point)
Finds the node under a point, considering hit testing.
Used for mouse picking. Recursively searches children (in reverse order) to find the topmost node containing the point. Only nodes with the OVER_FIND_ALLOWED flag are considered.
Parameters:
Point |
The point to test in world coordinates. |
Returns:
The topmost node at that point, or nullptr.
void detach()
Removes the node from its parent.
Detaches this node from its parent without triggering deletion. After calling this, the node has no parent and must be managed manually.
Use with caution - this bypasses normal deletion lifecycle.
void forEachNode(std::function<void(Node*)> func)
Applies a function to this node and all descendants.
Traverses the entire subtree in depth-first order, calling func on each node.
Parameters:
func |
The function to apply to each node. |
void forEachChild(std::function<void(Node*)> func)
Applies a function to all direct children.
Calls func on each immediate child of this node (not including this node itself).
Parameters:
func |
The function to apply to each child. |
virtual void nodeDraw()
Performs the node’s custom drawing operations.
Virtual method that can be overridden to implement custom rendering. This is called during the draw cycle after the transform is set. The default implementation does nothing.
Uint32 forceKeyDown(const KeyEvent& event)
Simulates a key down event on this node.
Forces a key down event to be processed by this node, as if the user pressed a key while this node had focus.
Parameters:
event |
The key event to simulate. |
Returns:
The event handling result.
Uint32 foceKeyUp(const KeyEvent& event)
Simulates a key up event on this node.
Forces a key up event to be processed by this node.
Parameters:
event |
The key event to simulate. |
Returns:
The event handling result.
Uint32 forceTextInput(const TextInputEvent& Event)
Simulates a text input event on this node.
Forces a text input event to be processed by this node.
Parameters:
The text input event to simulate. |
Returns:
The event handling result.
const Vector2f& getScreenPos() const
Gets the screen-space position of this node.
Returns the computed position in actual screen pixels. This is the world position after all parent transformations have been applied.
Returns:
Const reference to the screen position as Vector2f.
Rectf getScreenRect() const
Gets the screen-space rectangle of this node.
Returns the node’s bounds in actual screen pixels as a rectangle.
Returns:
Rectf representing the screen-space bounds.
bool hasEventsOfType(const Uint32& eventType) const
Checks if this node has listeners for a specific event type.
Queries whether there are any event callbacks registered for the given event type on this node.
Parameters:
eventType |
The event type to check. |
Returns:
True if listeners exist, false otherwise.