RADLib
RADical C++ application framework
RADUi::ButtonModel Class Reference

Push-button state model. More...

#include <RADWidgets.h>

+ Inheritance diagram for RADUi::ButtonModel:
+ Collaboration diagram for RADUi::ButtonModel:

Public Member Functions

 ButtonModel (std::string text={})
 Creates a button model with optional text. More...
 
const std::string & text () const
 Returns button text. More...
 
void setText (std::string text)
 Updates button text. More...
 
bool isEnabled () const
 Returns true when the button can be clicked. More...
 
void setEnabled (bool enabled)
 Enables or disables the button. More...
 
void click ()
 Emits clicked when enabled. More...
 
- Public Member Functions inherited from RADCore::RADObject
 RADObject ()
 Creates a RADObject bound to the current thread. More...
 
virtual ~RADObject ()
 Disconnects tracked event links and releases lifetime token. More...
 
void registerLink (const ConnectionRecord &record)
 Registers a connection for cleanup when this object is destroyed. More...
 
std::thread::id threadId () const
 Returns the thread id this object is currently associated with. More...
 
EventLoopassociatedEventLoop () const
 Returns the associated event loop, if any. More...
 
ThreadAffinity threadAffinity () const
 Returns both thread id and associated loop atomically. More...
 
std::weak_ptr< void > lifetimeToken () const
 Returns a weak token used to drop queued callbacks after destruction. More...
 
void moveToThread (std::thread::id tId, EventLoop *loop=nullptr)
 Moves the object's affinity to tId and optional loop. More...
 

Public Attributes

RADCore::Event< void() > changed
 Raised when text or enabled state changes. More...
 
RADCore::Event< void() > clicked
 Raised when click() is called while enabled. More...
 

Detailed Description

Push-button state model.

Constructor & Destructor Documentation

◆ ButtonModel()

RADUi::ButtonModel::ButtonModel ( std::string  text = {})
explicit

Creates a button model with optional text.

Member Function Documentation

◆ click()

void RADUi::ButtonModel::click ( )

Emits clicked when enabled.

◆ isEnabled()

bool RADUi::ButtonModel::isEnabled ( ) const

Returns true when the button can be clicked.

◆ setEnabled()

void RADUi::ButtonModel::setEnabled ( bool  enabled)

Enables or disables the button.

◆ setText()

void RADUi::ButtonModel::setText ( std::string  text)

Updates button text.

◆ text()

const std::string& RADUi::ButtonModel::text ( ) const

Returns button text.

Member Data Documentation

◆ changed

RADCore::Event<void () > RADUi::ButtonModel::changed

Raised when text or enabled state changes.

◆ clicked

RADCore::Event<void () > RADUi::ButtonModel::clicked

Raised when click() is called while enabled.


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