slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.54k stars 600 forks source link

Button stays "highlighted" when covered by another TouchArea #2919

Closed tp971 closed 1 year ago

tp971 commented 1 year ago

This came up while trying to implement a "modal dialog" using a transparent rectangle with a TouchArea covering the window: If a button is pressed and the clicked callback makes TouchArea visible that covers the point where the button was clicked, the button stays in a "highlighted" state. Here is a simplified example:

fn main() {
    MainWindow::new().unwrap().run().unwrap();
}

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

    export component MainWindow inherits Window {
        width: 200px;
        height: 200px;

        Button {
            x: 10px;
            y: 10px;
            text: "Open";
            clicked => { r.visible = true; }
        }

        r := Rectangle {
            width: parent.width;
            height: parent.height;
            visible: false;
            TouchArea {}
            Button {
                x: 100px;
                y: 100px;
                text: "Close";
                clicked => { r.visible = false; }
            }
        }
    }
}

It is pretty noticable in the fluent-dark style:

Before pressing the button: before

After pressing the button: after

ogoffart commented 1 year ago

Thanks for the detailed report.

Could reproduce with 1.0.2, but this is fixed in master. (presumably fixed by https://github.com/slint-ui/slint/pull/2745 )