I’m using iced to manage my GUI in association with rfd to show error message, and file dialog.
Sadly, on Windows, the rfd windows do not appear in foreground but in background. It seems to come from the fact that I did not pass a WindowHandle as parent.
So I tried to find a way to get the windowHandle of the focused iced window, using subscription, I got its ID.
And it seems that the only way to obtain the WindowHandle from here is to use the run_with_handle function. But this function returns a task, so I would need a way to run this Task to its completion to get the result of the call I made.
fn custom_expect(self: Result<T, Err>, msg: &str) -> T {
if let Err(e) = self {
let dialog = // Create the dialog box with red
run_with_hadle(
ID, // global car defined as the last focused window
|handle| dialog.set_parent(handle).show(),
)
}
self.expect(msg)
}
The idea is to show a reason why the program crashed to a user that wouldn’t be using a console
Because on Linux the dialog is shown in foreground automatically if it doesn’t have a parents
But it seems that the focus stealing prevention on windows, puts the error message in background, so the user has the impression that the software just crashed.
I don’t know if it’s possible in the current version of iced
But it seems interesting to run a task in a blocking way, when you can’t abide to have something delayed