mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
Move from function pointers to std::function
This commit is contained in:
@@ -5,16 +5,11 @@ UI_combobox::UI_combobox()
|
||||
{
|
||||
}
|
||||
|
||||
UI_combobox::UI_combobox(std::string id, std::string text, Color fg_color, Color bg_color, std::vector<std::string> options, size_t selected, UI_combobox_on_change on_change)
|
||||
UI_combobox::UI_combobox(std::string id, std::string text, Color fg_color, Color bg_color, std::vector<std::string> options, size_t selected, std::function<void(std::string, std::string)> on_change)
|
||||
: UI_x_boxes(id, UI_COMBOBOX_TYPE, text, fg_color, bg_color, options), p_selected(selected), p_on_change(on_change)
|
||||
{
|
||||
}
|
||||
|
||||
UI_combobox::UI_combobox(std::string id, std::string text, Color fg_color, Color bg_color, std::vector<std::string> options, UI_combobox_on_change on_change)
|
||||
: UI_x_boxes(id, UI_COMBOBOX_TYPE, text, fg_color, bg_color, options), p_selected(0), p_on_change(on_change)
|
||||
{
|
||||
}
|
||||
|
||||
UI_combobox::UI_combobox(const json& j)
|
||||
: UI_x_boxes(UI_COMBOBOX_TYPE), p_on_change(nullptr)
|
||||
{
|
||||
@@ -28,7 +23,7 @@ void UI_combobox::set_selected(size_t selected)
|
||||
p_selected = selected;
|
||||
if (p_on_change != nullptr)
|
||||
{
|
||||
p_on_change(p_id, selected);
|
||||
p_on_change(p_id, selected_text());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user