Skip to content

Commit 95ca137

Browse files
committed
Add ButtonEventHandler::isHovered, fix setActive()
Signed-off-by: falkTX <falktx@falktx.com>
1 parent 766e138 commit 95ca137

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

dgl/EventHandlers.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class ButtonEventHandler
6666
bool isEnabled() const noexcept;
6767
void setEnabled(bool enabled, bool appliesToEventInput = true) noexcept;
6868

69+
bool isHovered() const noexcept;
70+
6971
Point<double> getLastClickPosition() const noexcept;
7072
Point<double> getLastMotionPosition() const noexcept;
7173

dgl/src/EventHandlers.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ struct ButtonEventHandler::PrivateData {
145145
if (active == active2)
146146
return;
147147

148-
state |= kButtonStateActive;
148+
if (active2)
149+
state |= kButtonStateActive;
150+
else
151+
state &= ~kButtonStateActive;
152+
149153
widget->repaint();
150154

151155
if (sendCallback)
@@ -251,6 +255,11 @@ void ButtonEventHandler::setEnabled(const bool enabled, const bool appliesToEven
251255
pData->setEnabled(enabled, appliesToEventInput);
252256
}
253257

258+
bool ButtonEventHandler::isHovered() const noexcept
259+
{
260+
return (pData->state & ButtonEventHandler::kButtonStateHover) != 0;
261+
}
262+
254263
Point<double> ButtonEventHandler::getLastClickPosition() const noexcept
255264
{
256265
return pData->lastClickPos;

0 commit comments

Comments
 (0)