Iced: Close window ?

Created on 20 Mar 2020  路  5Comments  路  Source: hecrj/iced

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.

feature

Most helpful comment

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.

All 5 comments

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.

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.

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.

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CallistoM picture CallistoM  路  3Comments

olanod picture olanod  路  4Comments

casperstorm picture casperstorm  路  3Comments

Gohla picture Gohla  路  4Comments

Plecra picture Plecra  路  4Comments