Closing button #3562
-
Hello, I'am doing a graphic interface using slint with rust. thanks |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
The way i'm currently doing it, is by getting an event from the ui and then using process::exit() in my rust code. |
Beta Was this translation helpful? Give feedback.
-
(Note: I've moved this issue to Discussions as it's better suited for general questions and community interactions. This helps keep our issue tracker focused on bug reports and feature requests) The way to do what you want is to have a callback that closes the window from native code. fn main() {
slint::slint! {
import { Button } from "std-widgets.slint";
export component Win inherits Window {
callback close();
Button { text: "Close"; clicked => { close(); } }
}
}
let win = Win::new().unwrap();
let weak = win.as_weak();
win.on_close(move || weak.unwrap().window().hide().unwrap());
win.run().unwrap();
} |
Beta Was this translation helpful? Give feedback.
-
Yes thanks for the feedback.
But I think that window::hide, doesn’t kill the process.
|
Beta Was this translation helpful? Give feedback.
-
also this could work: app.on_cls_win(|| {
// std::process::exit(0);
slint::quit_event_loop().unwrap();
}); |
Beta Was this translation helpful? Give feedback.
(Note: I've moved this issue to Discussions as it's better suited for general questions and community interactions. This helps keep our issue tracker focused on bug reports and feature requests)
The way to do what you want is to have a callback that closes the window from native code.