Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Button

Add this in your code:

#include <engine/graphics/ui/button.h>

Description

Component that renders a button on the screen.

Variables


NameTypeDescription
colorColorColor of the sprite

Public methods


GetOrderInLayer

Get the order in layer, higher number, higher priority.

int GetOrderInLayer() const

SetOrderInLayer

Set the order in layer.

Parameters:

  • orderInLayer: Order in layer, higher number, higher priority
void SetOrderInLayer(int orderInLayer)

GetImage

Get the image.

const std::shared_ptr<Texture>& GetImage() const

SetImage

Set the image.

Parameters:

  • image: Image to use
void SetImage(const std::shared_ptr<Texture>& image)

GetOnClickEvent

Get the onClick event, called when the user clicks on the button.

Event<>& GetOnClickEvent()

Code sample:

class MyClass
{
public:
    void OnClick() { }
};

std::shared_ptr<Button> button; // Filled variable
MyClass myClassInstance = MyClass();

button->GetOnClickEvent().Bind(&MyClass::MyStaticFunction, &myClassInstance);