mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 07:44:57 +00:00
LibCore+LibGUI+WindowServer: Make events bubble up through ancestors
With this patch, CEvents no longer stop at the target object, but will bubble up the ancestor chain as long as CEvent::is_accepted() is false. To the set accepted flag, call CEvent::accept(). To clear the accepted flag, call CEvent::ignore(). Events start out in the accepted state, so if you want them to bubble up, you have to call ignore() on them. Using this mechanism, we now ignore non-tabbing keydown events in GWidget, causing them to bubble up through the widget's ancestors. :^)
This commit is contained in:
parent
74c4e62659
commit
fcc3745b02
9 changed files with 54 additions and 17 deletions
|
@ -122,7 +122,7 @@ void GWidget::handle_paint_event(GPaintEvent& event)
|
|||
return IterationDecision::Continue;
|
||||
if (child.relative_rect().intersects(event.rect())) {
|
||||
GPaintEvent local_event(event.rect().intersected(child.relative_rect()).translated(-child.relative_position()));
|
||||
child.event(local_event);
|
||||
child.dispatch_event(local_event, this);
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
@ -231,7 +231,10 @@ void GWidget::keydown_event(GKeyEvent& event)
|
|||
focus_previous_widget();
|
||||
else
|
||||
focus_next_widget();
|
||||
event.accept();
|
||||
return;
|
||||
}
|
||||
event.ignore();
|
||||
}
|
||||
|
||||
void GWidget::keyup_event(GKeyEvent&)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue