How to use egui + winit so I have control over the event loop? #5772
Replies: 3 comments
-
Hello everyone, This would be very useful for me as well. I tried to open the instrument’s GUI by pushing a button in egui. Unfortunately, the plugins are encapsulated by the vendor and create their own user interface. Therefore, I need access to the event loop. I tried the examples external_eventloop and external_eventloop_async. Unfortunately, I couldn’t successfully open both the egui and the external encapsulated view. I like the new interface in terms of access to the event_loop, but I don’t know how to access the event_loop from inside. Typically, I would use a proxy to call a custom event. That event would then be handled within the closure of the event loop, where I have access to everything. The external_eventloop example uses an event loop bound to UserEvent (EventLoop). It’s easy to get a proxy with event_loop.create_proxy(), but I can’t inject my custom events. I need sth like: UserEvent::OpenPluginWindow(plugin_id) => {
// Open external GUI-Window here
} from inside the event_loop. Am I missing something here, or does someone know a best practice? I’m still new to Rust, so maybe I’ve overlooked something. For now, it looks like egui is eating up the whole winit run loop. On macOS, for example, I can’t create another one — not even in another thread. Linux behaves differently. I would like to have one application which uses the event_loop to control new windows. My goal is to: |
Beta Was this translation helpful? Give feedback.
-
I've needed access to the winit event loop to implement a tray icon app with egui. I found the pure_glow example particularly useful. https://github.com/emilk/egui/blob/main/crates/egui_glow/examples/pure_glow.rs I don't know for sure if it will meet your needs, but it is worth evaluating. |
Beta Was this translation helpful? Give feedback.
-
Here is an example with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to have direct control over the display connection and windows, but every example I can find uses some sort of callback, either through
run_native
or some sort ofApp
trait.I'm pretty sure I need to use
egui_winit
to translate between winit events and egui events, but i'm not sure how to.Beta Was this translation helpful? Give feedback.
All reactions