mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +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:
@@ -124,3 +124,16 @@ void GAbstractButton::paint_text(GPainter& painter, const Rect& rect, const Font
|
||||
if (is_focused())
|
||||
painter.draw_rect(clipped_rect.inflated(6, 4), Color(140, 140, 140));
|
||||
}
|
||||
|
||||
void GAbstractButton::change_event(GEvent& event)
|
||||
{
|
||||
if (event.type() == GEvent::Type::EnabledChange) {
|
||||
if (!is_enabled()) {
|
||||
bool was_being_pressed = m_being_pressed;
|
||||
m_being_pressed = false;
|
||||
if (was_being_pressed)
|
||||
update();
|
||||
}
|
||||
}
|
||||
GWidget::change_event(event);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user