|
Ultralight C++ API 2.0.0
|
#include <AppCore/layout/Callback.h>
Scoped handle that controls how long a layout callback stays registered.
Methods that register layout and panel callbacks return a LayoutCallback. The callback stays active for as long as this handle exists.
To keep receiving events, store the handle in an object whose lifetime matches the listener.
This status bar keeps a focus-change callback as a member variable:
A registered callback stops firing when:
Call IsActive() to check whether the callback can still fire.
To keep a callback running without storing its handle, call Detach(). The callback remains registered for the rest of the node's lifetime. Once detached, the callback can't be removed.
Chain Detach() onto the registration call:
Public Member Functions | |
| LayoutCallback () | |
| Create an empty LayoutCallback (it owns no registration and IsActive() is false). | |
| LayoutCallback (const LayoutCallback &)=delete | |
| LayoutCallback & | operator= (const LayoutCallback &)=delete |
| LayoutCallback (LayoutCallback &&other) noexcept | |
| Move constructor (transfers the registration, other becomes empty). | |
| LayoutCallback & | operator= (LayoutCallback &&other) noexcept |
| Move assignment. | |
| ~LayoutCallback () | |
| Unregister the callback (if it is still registered) and release the registration. | |
| operator bool () const | |
| Whether or not the callback can still fire. | |
| bool | IsActive () const |
| The named form of operator bool. | |
| void | Remove () |
| Stop receiving callbacks now. | |
| void | Detach () |
| Leave the callback registered for the rest of its node's lifetime and give up this object. | |
| LayoutCallback | ( | ) |
Create an empty LayoutCallback (it owns no registration and IsActive() is false).
|
delete |
|
noexcept |
Move constructor (transfers the registration, other becomes empty).
| ~LayoutCallback | ( | ) |
Unregister the callback (if it is still registered) and release the registration.
| void Detach | ( | ) |
Leave the callback registered for the rest of its node's lifetime and give up this object.
The callback keeps firing until the node is removed or its window closes. There is no way to remove it afterwards.
| bool IsActive | ( | ) | const |
The named form of operator bool.
|
inlineexplicit |
Whether or not the callback can still fire.
This is false for an empty object, after Remove(), and once the node is removed or its window closes.
|
delete |
|
noexcept |
Move assignment.
Removes any registration this object held, then takes over other's.
| void Remove | ( | ) |
Stop receiving callbacks now.
You can call this more than once, after the node is removed or its window closes, and from inside the callback itself.