-
-
Notifications
You must be signed in to change notification settings - Fork 53
Button
Otavio edited this page Jul 21, 2021
·
9 revisions
Introduction: Buttons are type of Widgets, used to Trigger a Callback which do something fancy.
Parameters:
AddCallback takes a std::function<void()>
argument.
See CWidgets::AddCallback
Setting up a Callback
void btn_callback()
{
std::cout << "Callback Triggered" << std::endl;
}
Now we can create a Button with our Callback:
std::shared_ptr<FGUI::CButton> Button;
Button = std::make_shared<FGUI::CButton>();
buildrPattern.Widget(Button).Title("Example Button").Font("Tahoma", 13, true).
Callback(btn_callback).SpawnIn(Container);
Learn more about Builder Pattern here. After adding this Button into your menu, whenever you click the button it will call the function we created above.
RESULT: Callback Triggered
Next you will learn about the CheckBox Widget.
You can also read the library comments/functions for additional info.