Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling combobox value changing with scrolling #5929

Open
JakubKoralewski opened this issue Aug 24, 2024 · 4 comments · May be fixed by #7485
Open

Allow disabling combobox value changing with scrolling #5929

JakubKoralewski opened this issue Aug 24, 2024 · 4 comments · May be fixed by #7485
Labels
a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS) enhancement New feature or request

Comments

@JakubKoralewski
Copy link

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"];
            }
        }
    }
}
@ogoffart
Copy link
Member

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 ogoffart added enhancement New feature or request a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS) labels Aug 26, 2024
@task-jp
Copy link
Contributor

task-jp commented Dec 19, 2024

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.

@NigelBreslaw
Copy link
Member

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.

@ogoffart
Copy link
Member

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

ogoffart added a commit that referenced this issue Jan 28, 2025
This is what native Windows combobox does.
Otherwise this causes problem when combobox are in scrollable

Fixes #5929
@ogoffart ogoffart linked a pull request Jan 28, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS) enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants