1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 11:35:07 +00:00

LibGUI: Notify widgets when their enabled state changes.

This is done by dispatching a (synchronous) "EnabledChange" event that can
be picked up in change_event(). Use this event to kick widgets out of their
"being pressed"-type modes if the user is interacting with them while the
state is programmatically changed.
This commit is contained in:
Andreas Kling 2019-05-25 13:40:57 +02:00
parent e478a2fb0a
commit d12857fc36
9 changed files with 44 additions and 0 deletions

View file

@ -94,6 +94,8 @@ void GWidget::event(CEvent& event)
return handle_enter_event(event);
case GEvent::Leave:
return handle_leave_event(event);
case GEvent::EnabledChange:
return change_event(static_cast<GEvent&>(event));
default:
return CObject::event(event);
}
@ -271,6 +273,10 @@ void GWidget::leave_event(CEvent&)
{
}
void GWidget::change_event(GEvent&)
{
}
void GWidget::update()
{
if (rect().is_empty())
@ -454,6 +460,8 @@ void GWidget::set_enabled(bool enabled)
if (m_enabled == enabled)
return;
m_enabled = enabled;
GEvent e(GEvent::EnabledChange);
event(e);
update();
}