Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
BindButton Class Reference

The BindButton class represents a button UI element for use with BindCanvas. More...

`#include <BindButton.hpp>`

Inheritance diagram for BindButton:

## Public Member Functions
| BindButton (const char *cstr)
| Constructs a BindButton with a custom label.
void | setlabel (const char *cstr)
void | setLabel (const char *cstr)
| Sets the callback function for the button.
void | setCallback (void(*callback)(void))
| Set the press callback function for the button.
void | invokeCallback ()
uint16_t | getBytes (uint8_t *out) override
| Retrieves the bytes representing the button for synchronization.

## Public Attributes
int16_t | x
| X-coordinate position of the button.
int16_t | y
| Y-coordinate position of the button.
uint8_t | cmdId = 0
| Command ID for the button. See the notes for possible cmdId values.
int16_t | fontSize = 16
| Font size of the button's label.
int32_t | textColor = WHITE
| Text color of the button.
int32_t | backColor = BLUE
| Background color of the button.
Public Attributes inherited from BindView
int16_t | tag

## Detailed Description

The BindButton class represents a button UI element for use with BindCanvas.

BindButton

BindButton is a class that defines a button UI element that can be used within BindCanvas-based applications. It inherits from the BindView class and provides functionality to create and customize buttons, including setting labels, positions, colors, and sizes.

Note
  Possible cmdId values for a BindView and corresponding effects:
  - BIND_ADD_OR_REFRESH_CMD: Adds the object to the canvas (screen) or refreshes the existing one.
  - BIND_DATA_ONLY_CMD: Refreshes the existing object without moving or resizing; updates data, such as text.
  - BIND_REMOVE_CMD: Removes the object from the canvas (screen).
  - BIND_DISABLE_CMD: Disables the object.
  - BIND_ENABLE_CMD: Enables the object.
  - BIND_HIDE_CMD: Hides the object.
  - BIND_VISIBLE_CMD: Restores the object's visibility.

Buttons created with BindButton can be synchronized with BindCanvas through the Bind framework, allowing interactive user interfaces to be built for various applications.

Note
  To receive touch events and user interactions, you must regularly call `bind.sync()` in your main loop.

## Constructor & Destructor Documentation

## ◆ BindButton()

BindButton::BindButton | ( | const char * | cstr | ) |
| inline

Constructs a BindButton with a custom label.

This constructor creates a BindButton with a custom text label. The label can be used to define the button's text content.

Parameters

  cstr | A pointer to the character array representing the custom label for the button.

## Member Function Documentation

## ◆ getBytes()

uint16_t BindButton::getBytes | ( | uint8_t * | out | ) |
| inline override virtual

Retrieves the bytes representing the button for synchronization.

This function is used to gather the bytes that represent the button's properties for synchronization.

Note
  This function should not be called directly by users, Bind calls it internally.

Parameters

  out | A pointer to the output buffer where the button data will be stored.

Returns
  The number of bytes written to the output buffer.

Reimplemented from BindView.

## ◆ setCallback()

void BindButton::setCallback | ( | void(*)(void) | callback | ) |
| inline

Set the press callback function for the button.

This callback function is called when the button is pressed. The signature of the callback function should be like:backColor

void callback()

Parameters

  callback |

## ◆ setLabel()

void BindButton::setLabel | ( | const char * | cstr | ) |
| inline

Sets the callback function for the button.

This function allows you to set a callback function for the button. The callback function is invoked when the button is clicked.

Note
  You need to sync the button, e.g. call bind.sync(bindButton).

Parameters

  callback | A pointer to the callback function.

The documentation for this class was generated from the following files:

- BindButton.hpp
- Bind.cpp