-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I build a new window inside run_forever or poll_events? #413
Comments
One option is to simply break out of the event loop in that case: loop {
let mut flag = false;
events.run_forever(|event| {
match event {
// Event you care about
flag = true;
return ControlFlow::Break;
}
});
if flag {
windows.push(Window::new(&events));
}
} |
Sure, but that's not inside the callback :-p |
oh, I misread your comment; I didn't really notice that you could call run forever again |
I've encountered the same problem. I think what could be easily done to solve the problem is to add events.run_forever_mut(|event, events| { .... /* you can now use "events" to create new window here */ } I hope rust allows it :) To have backward compatible API it could be a new method like -- Or.. other idea.. is to use interior mutability for EventsLoop. In that case it would be easy to pass the reference to EventLoop anywhere. |
This should be fixed by the EventLoop 2.0 API rework, when that gets merged. |
…lton Add ColorMatrix filter
Now you'd use the EventLoopWindowTarget that you get in the run method, right? |
Yes, new windows are created with |
I'd like to be able to spawn a new window in response to user input.
Since the event loop is borrowed mutably by
run_forever
andpoll_events
, there doesn't appear to be a way to spawn new windows in response to input events.This may be another facet of #231
The text was updated successfully, but these errors were encountered: