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.06k stars 573 forks source link

PopupWindow focus handling #2911

Open tronical opened 1 year ago

tronical commented 1 year ago

Following up on #1143 and related slightly to #2899 :

Suppose a PopupWindow declares a bunch of buttons:

    confirm_popup := PopupWindow {
        x: 40px;
        y: 100px;
        width: min(confirm_popup_layout.preferred-width, root.width - 80px);
        forward-focus: yes-button;
        Rectangle {
            background: root.background;
            border-color: confirm_popup_text.color;
            border-width: 1px;
        }
        confirm_popup_layout := Dialog {
            height:100%; width: 100%;
            confirm_popup_text := Text {
                text: "Some items are not done, are you sure you wish to quit?";
                wrap: word-wrap;
            }
            yes-button := StandardButton { kind: yes; clicked => { root.popup_confirmed(); } }
            StandardButton { kind: no; }
        }
    }

When this popup is down what should happen is:

1) The underlying window that created the popup does not show activate focus anymore 2) Focus is transferred to the popup and consequently to the yes/ok button. 3) Tab-focus should allow transferring focus between the buttons.

With Qt this almost works, except that the initial focus isn't shown.

With winit, which currently embeds the popup inline, none of the three points work.

almindor commented 1 year ago

One thing to note here is that in wayland/sway where focus can change by just moving the mouse, this bug has even bigger implications. Just moving the mouse over to another app/windows while a popup is out will close it without any way of getting a notification to the effect. This means that there's no good way "around" the issue so that user interaction loops can be "closed".

ogoffart commented 1 year ago

@almindor does it also happen when close-on-click is set to false?

almindor commented 1 year ago

@almindor does it also happen when close-on-click is set to false?

Yes