Skip to content

Switch 1 sets Switch 2 ... Binding lost? #7108

Answered by mcitem
dirkeinecke asked this question in Q&A
Discussion options

You must be logged in to vote
use slint::Weak;

slint::slint! {
import { Switch } from "std-widgets.slint";

export component App inherits Window {
    in property <bool> checked_1 <=> switch_1.checked;
    in property <bool> checked_2 <=> switch_2.checked;
    callback toggled_1 <=> switch_1.toggled;
    callback toggled_2 <=> switch_2.toggled;
    width: 100px;
    height: 100px;
    VerticalLayout {
        switch_1 := Switch {
            text: "Switch 1";
        }
        switch_2 := Switch {
            text: "Switch 2";
        }
    }
}
}

fn main() {
    let app: App = App::new().unwrap();

    let weak_1: Weak<App> = app.as_weak();
    app.on_toggled_1(move || {
        if let Some(app) = weak_1.upgrade() {

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
8 replies
@hunger
Comment options

hunger Dec 16, 2024
Collaborator

@dirkeinecke
Comment options

@mcitem
Comment options

@dirkeinecke
Comment options

@mcitem
Comment options

Comment options

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

Answer selected by dirkeinecke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants