HoverAPI

GDNatrium

HoverAPI

An API for calling functions when starting or stopping to hover a node. Intended for developers, has no functionality on it's own.


Usage

You can use this API as a dependency by declaring it in your mod.json file:

{
    "dependencies": [
        {
            "id": "natrium.hoverapi",
            "version": "1.0.0"
        }
    ]
}

Afterwards, include this header:

#include <natrium.hoverapi/include/Hover.hpp>

Check below for an example usage.


Functions

static Hover* get(CCNode* parent);
Get a Hover instance attached to the given parent node. If one already exists, it is returned; otherwise, a new instance is created.

void watch(CCNode node, std::function<void(CCNode)> onEnter, std::function<void(CCNode)> onExit);
Starts watching the given node for hover events. onEnter and onExit are optional callbacks for the respective event.

void forget(CCNode node);
Stops watching the given node for hover events.

void clear();
Stops watching all nodes and clears hover states.

bool isHovering(CCNode node) const;
Returns whether a given node is currently hovered.

bool isWatched(CCNode node) const;
Returns whether a given node is currently watched.

const std::vector<CCNode*>& getWatchedNodes() const;
Returns all currently watched nodes.

HoverEntry* getHoverHandlers(CCNode node);
Returns the HoverEntry (handlers) for a given node, or nullptr if none registered.

CCRect getHoverRect(CCNode node) const;
Returns the CCRect of a given node hover.

void setHoverPadding(CCNode node, float padding);
Adds padding to the hover of a given node to extend the hitbox.

void setOffset(CCNode node, CCPoint offset);
Offsets the hover hitbox of a given node.


Fields

bool m_respectZOrder;
Sets whether nodes that are above the hover's parent node pause the hovering. For example, whether popups should pause hovers on the layer below until closed. False by default.

bool m_debugDrawEnabled;
Draws borders around the hovers. False by default.

ccColor4F m_debugDrawColor;
Color of the debug draw borders. Cyan ({ 0, 1, 1, 1}) by default.


Usage Example

This example makes the profile button turn green and scale by 1.25 on hover start, and revert on hover end.

#include <Geode/Geode.hpp>

using namespace geode::prelude;

#include <Geode/modify/MenuLayer.hpp>

// Dependency for the HoverAPI
#include <natrium.hoverapi/include/Hover.hpp>

class $modify(MenuLayer) {
  bool init() {
    if (!MenuLayer::init()) {
      return false;
    }

    // Get the hover instance
    auto hover = Hover::get(this);

    // Start watching the profile button
    hover->watch(m_profileButton,
      [](CCNode* n) {

        // This gets called onEnter
        auto spr = n->getChildByType<CCSprite>(0);
        spr->setColor(ccc3(0, 255, 0));
        spr->setScale(1.25f);
      },
      [](CCNode* n) {

        // This gets called onExit
        auto spr = n->getChildByType<CCSprite>(0);
        spr->setColor(ccc3(255, 255, 255));
        spr->setScale(1.f);
      });

    return true;
  }
};

1.0.0

  • Release
The recommended way to install mods is through the in-game mod loader . You will have to manually install the .geode files you get from this page.

Some mods also require other mods as dependencies ; you will need to find and install them yourself.

Site made by HJfod . Thank you to nekit for the domain!

Geode Team 2025