-
-
Notifications
You must be signed in to change notification settings - Fork 53
Button
Otavio edited this page Jul 23, 2021
·
9 revisions
Buttons is a widget used to trigger a specific callback (Function).
When a callback is set, whenever you click the Button widget it will trigger that callback, in other words it will call the function that you set for your button.
You will need to declare a pointer for your widget and to initialize it:
std::shared_ptr<FGUI::CButton> Button;
You'll also need a callback to trigger.
void MyCustomCallback() {
ICVar->ConsoleColorPrintf(255, 255, 0, 255, "callback called!\n");
}
Now you can start setting up your widget usign the Builder Pattern.
FGUI::CBuilder buildrPattern;
// Button
Button = std::make_shared<FGUI::CButton>();
buildrPattern.Widget(Button).Title("Click Me!").Font("Tahoma", 12, true).Callback(MyCustomCallback).SpawnIn(Container);
("MyCustomCallback"
) is the function that you want to trigger when clicking the Button.
callback called!
Next you will learn about the CheckBox Widget.
You can also read the library comments/functions for additional info.