Skip to content

Commit

Permalink
GUI2: added helper to execute a function with a found widget as its a…
Browse files Browse the repository at this point in the history
…rgument
  • Loading branch information
Vultraz committed Feb 20, 2021
1 parent 1f3a90c commit 34cb0c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gui/auxiliary/find_widget.hpp
Expand Up @@ -99,4 +99,11 @@ T& find_widget(utils::const_clone_ptr<widget, T> widget,
return *find_widget<T>(widget, id, must_be_active, true);
}

template<typename T>
void on_widget(utils::const_clone_ptr<widget, T> parent, const std::string& id, std::function<void(T&)> func)
{
if(auto widget = find_widget<T>(parent, id, false, false)) {
func(*widget);
}
}
} // namespace gui2

0 comments on commit 34cb0c8

Please sign in to comment.