slint icon indicating copy to clipboard operation
slint copied to clipboard

Allow disabling combobox value changing with scrolling

Open JakubKoralewski opened this issue 1 year ago • 1 comments

When a ComboBox is set inside ScrollView it is easy to make the mistake of editing the ComboBox by hovering over the ComboBox and scrolling on the ComboBox instead of an empty part of the window. When ComboBox.width: 100%; this situation is inevitable.

I tried getting around this with a wrapper TouchArea catching scroll events, but looks like the TouchArea would need to be inside the ComboBox for this to work.

import { AboutSlint, Button, VerticalBox, ScrollView, ComboBox } from "std-widgets.slint";
export component Demo {
    height: 300px;
    ScrollView 
    {
        VerticalLayout {
            padding: 50px;
            for i in 5 : TouchArea {
                height: 100px;
                ComboBox  {
                    height: 100%;
                    width: 100%;
                    
                    model: ["setting-a", "setting-b", "setting-c"];
                }
                scroll-event(ev) => {
                    EventResult.accept // since this controls whether parent element gets the event, this does nothing for the child combobox
                }
            }
            Text {
                text: "----";
            }
            for i in 5 : ComboBox  {
                height: 100px;
                model: ["setting-a", "setting-b", "setting-c"];
            }
        }
    }
}

JakubKoralewski avatar Aug 24 '24 09:08 JakubKoralewski

Thanks for the bug report. We should do the same as what the platform natively does. I tried Qt and the wheel does change the combobox even within scroll area. On windows, it seems that the wheel only change the content of the combobox if it has focus.

ogoffart avatar Aug 26 '24 09:08 ogoffart

I have disabled it in Qt Creator - https://codereview.qt-project.org/c/qt-creator/qt-creator/+/429103 Qt allows users to disable it thorugh style QStyle::SH_ComboBox_AllowWheelScrolling. I'm wondering if I can disable it through a property or an environment variable.

task-jp avatar Dec 19 '24 13:12 task-jp

This is causing a particular horrible issue with the Slint live-preview. You scroll the panel of visual properties and as the mouse moves over the combo boxes for unit types they get change from e.g. px to rem and lots of code is altered. Windows, Mac and I believe even linux don't have this by default regardless of if a combo box is in a scrollview or anywhere.

NigelBreslaw avatar Jan 28 '25 10:01 NigelBreslaw

One fix that could be done is to only allow this to work if the combobox has focus.

ogoffart avatar Jan 28 '25 10:01 ogoffart