Skip to content
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

Close window ? #226

Closed
Pascalio opened this issue Mar 20, 2020 · 6 comments · Fixed by #804
Closed

Close window ? #226

Pascalio opened this issue Mar 20, 2020 · 6 comments · Fixed by #804
Labels
feature New feature or request
Milestone

Comments

@Pascalio
Copy link

Is there any way to programmatically close the window ?
I'm evaluating the possibility to write a daemon that pops a window asking a question, then when the question is answered, the window must disappear without the user clicking the close button.

@hecrj hecrj added the feature New feature or request label Mar 21, 2020
@hecrj
Copy link
Member

hecrj commented Mar 21, 2020

There is currently no way to do this.

It should be easily implementable (maybe as part of Mode?), but we need to keep in mind that Application::run will never return. Therefore, closing the main window will exit the whole process.

Opening and closing windows from the same process is something that we should explore when tackling #27.

@hecrj hecrj added this to the 0.1.0 milestone Mar 21, 2020
@Friz64
Copy link
Contributor

Friz64 commented Mar 21, 2020

While not being the best solution, i think it might be possible to currently do this by taking control of the event loop yourself. The integration example might be a good starting point, you would just need to remove the scene code from the example. You would then just call Window::set_visible to show and hide your dialog.

@Pascalio
Copy link
Author

While not being the best solution, i think it might be possible to currently do this by taking control of the event loop yourself. The integration example might be a good starting point, you would just need to remove the scene code from the example. You would then just call Window::set_visible to show and hide your dialog.

Thank you. Yes, this seems to be a good way to do it by now. Or to *set control_flow to ControlFlow::Exit, to end the application on certain user interactions.

@Pascalio
Copy link
Author

There is currently no way to do this.

It should be easily implementable (maybe as part of Mode?), but we need to keep in mind that Application::run will never return. Therefore, closing the main window will exit the whole process.

Do you mean that Mode should have a variant like Unmapped or Invisible ? And we can just set this mode from the running code?

Opening and closing windows from the same process is something that we should explore when tackling #27.

@hecrj
Copy link
Member

hecrj commented Mar 26, 2020

This issue is somewhat related to #170. Maybe we should tackle both of them together.

Do you mean that Mode should have a variant like Unmapped or Invisible ?

Yes, I think an Invisible variant could work nicely.

And we can just set this mode from the running code?

The mode can be currently set in Application::mode.

@ardijanr
Copy link

ardijanr commented Jan 7, 2021

Currently this works, for killing the entire process thereby closing the open window. But looks your asking for something to close a spawned window, idk if those are spawned as their own process. If they are not then this would not work.

std::process::exit()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants