mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:47:44 +00:00
LibCore: Add CObject::for_each_child_of_type<T>()
Use this to iterate over all the GRadioButtons in a group.
This commit is contained in:
parent
0c85d3dba9
commit
3873c51781
3 changed files with 21 additions and 5 deletions
|
@ -55,9 +55,7 @@ void GRadioButton::for_each_in_group(Callback callback)
|
|||
{
|
||||
if (!parent())
|
||||
return;
|
||||
for_each_child_widget([&] (auto& child) {
|
||||
if (!child.is_radio_button())
|
||||
return IterationDecision::Continue;
|
||||
parent()->for_each_child_of_type<GRadioButton>([&] (auto& child) {
|
||||
return callback(static_cast<GRadioButton&>(child));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,3 +20,10 @@ private:
|
|||
template<typename Callback> void for_each_in_group(Callback);
|
||||
static Size circle_size();
|
||||
};
|
||||
|
||||
template<> inline bool is<GRadioButton>(const CObject& object)
|
||||
{
|
||||
if (!is<GWidget>(object))
|
||||
return false;
|
||||
return to<GWidget>(object).is_radio_button();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue