Skip to content
Discussion options

You must be logged in to vote

(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();
}

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@ogoffart
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by charleselie
Comment options

You must be logged in to vote
4 replies
@ogoffart
Comment options

@Horbin-Magician
Comment options

@ogoffart
Comment options

@Horbin-Magician
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #3555 on September 28, 2023 06:35.