class
ButtonButton widget.
Contents
Text and foreground. Emits tapped() signal on tap.
Styling
Ignores StateFlag::
Base classes
- class Widget
- Base for widgets.
Constructors, destructors, conversion operators
-
Button(Plane& plane,
const Anchor& anchor,
const std::
string& text, std:: size_t capacity = 0, Style style = Style:: Default) explicit - Constructor.
-
Button(Plane& plane,
const Anchor& anchor,
const std::
string& text, Style style) explicit -
template<std::Button(Plane& plane, const Anchor& anchor, const char(&text)[size], std::
size_t size> size_t capacity = 0, Style style = Style:: Default) explicit -
template<std::Button(Plane& plane, const Anchor& anchor, const char(&text)[size], Style style) explicit
size_t size> -
Button(Plane& plane,
const Anchor& anchor,
Containers::
ArrayView<const char> text, std:: size_t capacity = 0, Style style = Style:: Default) explicit -
Button(Plane& plane,
const Anchor& anchor,
Containers::
ArrayView<const char> text, Style style) explicit
Public functions
- void setStyle(Style style)
- Set widget style.
-
auto setText(const std::
string& text) -> Button& - Set text.
-
auto setText(Containers::
ArrayView<const char> text) -> Button& -
template<std::auto setText(const char(&text)[size]) -> Button&
size_t size> - auto tapped() -> Signal
- The button was tapped.
Private functions
- void update() override virtual
- Update the widget after its state changed.
- auto hoverEvent() override -> bool virtual
- Hover event.
- auto pressEvent() override -> bool virtual
- Press event.
- auto releaseEvent() override -> bool virtual
- Release event.
- auto focusEvent() override -> bool virtual
- Focus event.
Function documentation
Magnum:: Ui:: Button:: Button(Plane& plane,
const Anchor& anchor,
const std:: string& text,
std:: size_t capacity = 0,
Style style = Style:: Default) explicit
Constructor.
Parameters | |
---|---|
plane | Plane this widget is a part of |
anchor | Positioning anchor |
text | Button text |
capacity | Button text capacity (see setText()) |
style | Widget style |
Magnum:: Ui:: Button:: Button(Plane& plane,
const Anchor& anchor,
const std:: string& text,
Style style) explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<std:: size_t size>
Magnum:: Ui:: Button:: Button(Plane& plane,
const Anchor& anchor,
const char(&text)[size],
std:: size_t capacity = 0,
Style style = Style:: Default) explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<std:: size_t size>
Magnum:: Ui:: Button:: Button(Plane& plane,
const Anchor& anchor,
const char(&text)[size],
Style style) explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Magnum:: Ui:: Button:: Button(Plane& plane,
const Anchor& anchor,
Containers:: ArrayView<const char> text,
std:: size_t capacity = 0,
Style style = Style:: Default) explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Magnum:: Ui:: Button:: Button(Plane& plane,
const Anchor& anchor,
Containers:: ArrayView<const char> text,
Style style) explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Button& Magnum:: Ui:: Button:: setText(const std:: string& text)
Set text.
Returns | Reference to self (for method chaining) |
---|
The text is expected to not exceed the capacity defined in the constructor.
Button& Magnum:: Ui:: Button:: setText(Containers:: ArrayView<const char> text)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<std:: size_t size>
Button& Magnum:: Ui:: Button:: setText(const char(&text)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: Ui:: Button:: update() override virtual private
Update the widget after its state changed.
Expects to do only visual update, should not do any expensive operations like text relayouting.
bool Magnum:: Ui:: Button:: hoverEvent() override virtual private
Hover event.
Returns | True if the event was accepted, false if it was ignored |
---|
Called when the widget is hovered by the mouse or when the mouse leaves it again. Use Flag::false
.
bool Magnum:: Ui:: Button:: pressEvent() override virtual private
Press event.
Returns | True if the event was accepted, false if it was ignored |
---|
When the widget is pressed, Flag::false
.
bool Magnum:: Ui:: Button:: releaseEvent() override virtual private
Release event.
Returns | True if the event was accepted, false if it was ignored |
---|
On release after previous press event, Flag::false
.
bool Magnum:: Ui:: Button:: focusEvent() override virtual private
Focus event.
Returns | True if the event was accepted, false if it was ignored |
---|
If both press and release event happened on the same widget, Flag::false
.