ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
ZenitUI::UI::Button Class Reference

A push button. More...

#include <Button.hpp>

Inheritance diagram for ZenitUI::UI::Button:
[legend]

Public Member Functions

 Button (std::function< void()> cb)
 Construct a button with the given click handler.
std::string text () const
 Return the current label text, or "" if no Text child exists.
void setText (const std::string &s)
 Update the label text, creating a "btn-text" Text child if none exists.
Public Member Functions inherited from ZenitUI::TLayout< Button, Panel >
 TLayout (Args &&...args)
 Forward constructor arguments to Base.
std::shared_ptr< Button > cls (const std::string &name)
 Fluent addClass; returns typed shared_ptr<Derived>.
std::shared_ptr< Button > id (const std::string &node_id)
 Fluent setId; returns typed shared_ptr<Derived>.
std::shared_ptr< Button > withRef (const std::string &r)
 Fluent setRef; returns typed shared_ptr<Derived>.
std::shared_ptr< Button > size (Value w, Value h)
 Fluent setSize; returns typed shared_ptr<Derived>.
std::shared_ptr< Button > passThrough (bool p=true)
 Fluent setPassThrough; returns typed shared_ptr<Derived>.
std::shared_ptr< Button > with (std::shared_ptr< Layout > c)
 Fluent addChild; returns typed shared_ptr<Derived>.
std::shared_ptr< Button > self ()
 Return shared_from_this() statically cast to Derived.

Additional Inherited Members

Static Public Member Functions inherited from ZenitUI::TLayout< Button, Panel >
static std::shared_ptr< Button > create (Args &&...args)
 Construct a shared_ptr<Derived> and call onBuild().
Protected Member Functions inherited from ZenitUI::TLayout< Button, Panel >
virtual void onBuild ()
 Hook: called once after create() finishes constructing the object.

Detailed Description

A push button.

Style tag: "Button". Inherits from Panel so it shares its raycast and chrome behaviour. Keyboard-activatable (Enter / Space fire onClick).

Examples
05_data_binding/main.cpp, 14_desktop_workspace/main.cpp, 15_grid_dashboard/main.cpp, and 16_data_table/main.cpp.

Constructor & Destructor Documentation

◆ Button()

ZenitUI::UI::Button::Button ( std::function< void()> cb)
inline

Construct a button with the given click handler.

Parameters
cbHandler fired on click. May be empty; setText can still be used to add a label later.

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