UI: send events to children in reverse order

This commit is contained in:
Nikita Lisitsa 2021-03-06 10:56:22 +03:00
parent 1d0d90862e
commit e6506062b0

View file

@ -81,8 +81,9 @@ namespace psemek::ui
bool controller::impl::event(E const & e) bool controller::impl::event(E const & e)
{ {
auto visitor = util::recursive([&](auto && self, element * elem) -> bool { auto visitor = util::recursive([&](auto && self, element * elem) -> bool {
for (auto c : elem->children()) auto cs = elem->children();
if (c && self(c)) return true; for (auto it = cs.rbegin(); it != cs.rend(); ++it)
if (*it && self(*it)) return true;
if (elem->enabled() && elem->on_event(e)) return true; if (elem->enabled() && elem->on_event(e)) return true;
return false; return false;