Add ui::find_element_by_id
This commit is contained in:
parent
924533fc7f
commit
21ae912271
2 changed files with 21 additions and 0 deletions
|
|
@ -156,6 +156,8 @@ namespace psemek::ui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
element * find_element_by_id(element * root, std::string_view id);
|
||||||
|
|
||||||
void send_fake_mouse_move_event(element * e, bool mouseover);
|
void send_fake_mouse_move_event(element * e, bool mouseover);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,25 @@ namespace psemek::ui
|
||||||
c->post_delayed_callbacks();
|
c->post_delayed_callbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
element * find_element_by_id(element * root, std::string_view id)
|
||||||
|
{
|
||||||
|
auto visitor = util::recursive([&](auto && self, element * e) -> element *
|
||||||
|
{
|
||||||
|
if (!e) return nullptr;
|
||||||
|
|
||||||
|
if (e->id() && e->id() == id)
|
||||||
|
return e;
|
||||||
|
|
||||||
|
for (auto c : e->children())
|
||||||
|
if (auto r = self(c))
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
});
|
||||||
|
|
||||||
|
return visitor(root);
|
||||||
|
}
|
||||||
|
|
||||||
void send_fake_mouse_move_event(element * e, bool mouseover)
|
void send_fake_mouse_move_event(element * e, bool mouseover)
|
||||||
{
|
{
|
||||||
auto const box = e->shape().bbox();
|
auto const box = e->shape().bbox();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue