On 09/28/2017 05:23 PM, Stefan Seefeld via Boost wrote:
Event handler function called with on_*() prefix. Usually it is a class member functions. For example boost::ui::button::on_press(fn) calls fn when user clicks on button.
OK, so "button click" is an event type. Can I add my own ? And how is the connection to the handler established ?
No, Boost.UI not supports custom events. But there is boost::ui::widget::native_handle() function that returns native object and you can do with native widgets what you want, i. e. subscribe to custom events. But it isn't supported by Boost.UI. When you call on_press(fn) function, library stores fn inside library and when event raises it calls fn. You can subscribe multiple times at the same event. It works like Boost.Signals2, but uses only predefined GUI events/signals and not supports custom signals.
custom event types and sources may not be GUI related, but they need to be integrated with the application's main event loop. This kind of extensibility needs to be designed right into the API.
You can use boost::ui::call_async() to sync with main (GUI) event loop. https://kosenko.github.io/boost.ui/group__thread.html#ga3513f8b6cac36cac1d66... Regards, Kolya.