Add support for user-provided event loops & event handlers (#3180)

* added support for custom event loop
* added support for custom event callbacks
This commit is contained in:
Alex Andreba authored and GitHub committed 2024-11-13 18:44:29 -05:00
1 parent e7e624f05e
commit 1370bce182
3 files changed
+42 -4

No files matched your search

+5 -2
View File
@@ -53,8 +53,11 @@ pub(crate) struct SharedContext {
}
impl App {
pub fn new(cfg: Config, virtual_dom: VirtualDom) -> (EventLoop<UserWindowEvent>, Self) {
let event_loop = EventLoopBuilder::<UserWindowEvent>::with_user_event().build();
pub fn new(mut cfg: Config, virtual_dom: VirtualDom) -> (EventLoop<UserWindowEvent>, Self) {
let event_loop = cfg
.event_loop
.take()
.unwrap_or_else(|| EventLoopBuilder::<UserWindowEvent>::with_user_event().build());
let app = Self {
window_behavior: cfg.last_window_close_behavior,