BindDialog class represents a dialog box for use with BindCanvas app.
More...
#include <BindDialog.hpp>
|
| BindDialog (DialogType type=NO_INPUT_TEXT) |
|
void | setTitle (const char *cstr) |
| Set the title text for the dialog.
|
|
void | setMessage (const char *cstr) |
| Set the message text for the dialog.
|
|
void | setPrimaryButton (const char *cstr) |
| Set the primary button text (e.g. "OK") for the dialog.
|
|
void | setSecondaryButton (const char *cstr) |
| Set the secondary button text (e.g. "Cancel") for the dialog.
|
|
void | setCallback (void(*callback)(bool)) |
| Set the callback function for the dialog.
|
|
void | setCallback (void(*callback)(bool, const char *)) |
| Set the callback function for the dialog with text input.
|
|
void | invokeCallback (bool result, const char *text) |
|
void | invokeCallback (bool result) |
|
const char * | getResultText () const |
| Get the result text entered by the user.
|
|
uint16_t | getBytes (uint8_t *out) override |
| Retrieves the bytes representing the BindView for synchronization.
|
|
|
uint8_t | cmdId = 0 |
| Command ID for the dialog. See the notes for possible cmdId values.
|
|
bool | accepted = false |
| Result of the user interaction with the dialog.
|
|
bool | hasResult = false |
| Flag to indicate if the dialog has a result. The resets to false after each sync.
|
|
bool | singleButton = false |
| Flag to indicate if the dialog has a single button.
|
|
int16_t | tag |
|
BindDialog class represents a dialog box for use with BindCanvas app.
BindDialog
BindDialog Single Button
Password Dialog
BindDialog defines a popup dialog that can be shown with one or two buttons, optionally allowing text or password input. The user can set a title, message, button labels, and a callback to handle interaction.
Usage:
- Instantiate BindDialog with the desired DialogType.
- Set title, message, primaryButton, and optionally secondaryButton.
- Set a callback function for results (use setCallback(bool) or setCallback(bool, const char*) for text input).
- Call sync() to show the dialog on the screen.
◆ getBytes()
uint16_t BindDialog::getBytes |
( |
uint8_t * |
out | ) |
|
|
inlineoverridevirtual |
Retrieves the bytes representing the BindView for synchronization.
This function is used to gather the bytes that represent the BindView'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.
◆ getResultText()
const char * BindDialog::getResultText |
( |
| ) |
const |
|
inline |
Get the result text entered by the user.
This function returns the text entered by the user in the dialog. If no text was entered, it returns an empty string.
- Returns
- const char* The result text entered by the user.
◆ setCallback() [1/2]
void BindDialog::setCallback |
( |
void(*)(bool) |
callback | ) |
|
|
inline |
Set the callback function for the dialog.
The callback function is called when the user interacts with the dialog. The result of the user interaction is passed to the callback function as a boolean parameter. If the user clicks the primary button, the result is true. If the user clicks the secondary button, the result is false. The callback function should have the following signature:
void callback(bool result)
- Parameters
-
callback | Callback function for the dialog. |
◆ setCallback() [2/2]
void BindDialog::setCallback |
( |
void(*)(bool, const char *) |
callback | ) |
|
|
inline |
Set the callback function for the dialog with text input.
The callback function is called when the user interacts with the dialog. The result of the user interaction is passed to the callback function as a boolean parameter. If the user clicks the primary (submit) button, the result is true. If the user clicks outside the dialog or the secondary (cancel) button, the result will be false. Additionally, the text input by the user is passed as a parameter (*text). The callback function should have the following signature:
void callback(bool result, const char *text)
- Parameters
-
callback | Callback function for the dialog with text input. |
◆ setMessage()
void BindDialog::setMessage |
( |
const char * |
cstr | ) |
|
|
inline |
Set the message text for the dialog.
- Parameters
-
cstr | Message text for the dialog. |
◆ setPrimaryButton()
void BindDialog::setPrimaryButton |
( |
const char * |
cstr | ) |
|
|
inline |
Set the primary button text (e.g. "OK") for the dialog.
- Parameters
-
cstr | Primary button text for the dialog. |
◆ setSecondaryButton()
void BindDialog::setSecondaryButton |
( |
const char * |
cstr | ) |
|
|
inline |
Set the secondary button text (e.g. "Cancel") for the dialog.
- Parameters
-
cstr | Secondary button text for the dialog. |
◆ setTitle()
void BindDialog::setTitle |
( |
const char * |
cstr | ) |
|
|
inline |
Set the title text for the dialog.
- Parameters
-
cstr | Title text for the dialog. |
The documentation for this class was generated from the following files: