GButton: Update hovered state on mouseover as well.

We can't rely exclusively on enter and leave events to update the hovered
state, since leave will not be delivered while the widget is auto-tracking
the mouse (between mousedown and mouseup.)
This commit is contained in:
Andreas Kling 2019-05-01 18:53:05 +02:00
parent 288e97a206
commit b34f376329
Notes: sideshowbarker 2024-07-19 14:23:35 +09:00

View file

@ -65,9 +65,11 @@ void GButton::paint_event(GPaintEvent& event)
void GButton::mousemove_event(GMouseEvent& event)
{
bool is_over = rect().contains(event.position());
m_hovered = is_over;
if (event.buttons() & GMouseButton::Left) {
if (is_enabled()) {
bool being_pressed = rect().contains(event.position());
bool being_pressed = is_over;
if (being_pressed != m_being_pressed) {
m_being_pressed = being_pressed;
update();