add 'onmouseenter', 'onmouseleave' ui events

This commit is contained in:
MihailRis 2025-12-10 20:03:41 +03:00
parent d457b2ee7f
commit 78e0ac5a95
5 changed files with 36 additions and 1 deletions

View file

@ -52,6 +52,10 @@ void UINode::setHover(bool flag) {
return;
}
hover = flag;
actions.notify(flag ? UIAction::MOUSE_ENTER : UIAction::MOUSE_LEAVE, gui);
}
void UINode::setMouseOver(bool flag) {
actions.notify(flag ? UIAction::MOUSE_OVER : UIAction::MOUSE_OUT, gui);
}

View file

@ -59,7 +59,9 @@ namespace gui {
DEFOCUS,
RIGHT_CLICK,
MOUSE_OVER,
MOUSE_OUT
MOUSE_OUT,
MOUSE_ENTER,
MOUSE_LEAVE,
};
using ActionsSet = TaggedCallbacksSet<UIAction, GUI&>;
@ -170,8 +172,11 @@ namespace gui {
virtual void setHover(bool flag);
bool isHover() const;
void setMouseOver(bool flag);
virtual void setParent(UINode* node);
UINode* getParent() const;
std::shared_ptr<UINode> getParentShared() const;
/// @brief Set element color (doesn't affect inner elements).
/// Also replaces hover color to avoid adding extra properties