When I use the mouse wheel to scroll, any of the FC custom widgets that are touched by the cursor in passing increment or decrement their value. Don't think I've ever run into this in other applications.
Does anybody else notice this behaviour?
To me, the scroll wheel should only affect a widget's value if that widget already has focus via click or tab.
Thoughts?
Unwanted Value Changes in Custom Widgets
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Unwanted Value Changes in Custom Widgets
This is a super common phenomena in Scribus as well which uses Qt.wandererfan wrote: ↑Mon Jan 27, 2020 1:55 pm Does anybody else notice this behaviour?
To me, the scroll wheel should only affect a widget's value if that widget already has focus via click or tab.
Thoughts?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Unwanted Value Changes in Custom Widgets
It has pros (you can change a value without having to click on it first) and cons (you sometimes change value inadvertently).
I don't know if it's enough, but we could change focus policy of the spin boxes with :
At least we could test with some Python to see if it works.
I don't know if it's enough, but we could change focus policy of the spin boxes with :
Code: Select all
spinbox->setFocusPolicy(Qt::StrongFocus) #Default is Qt::WheelFocus which also accepts focus at wheel event
Re: Unwanted Value Changes in Custom Widgets
I would appreciate the extra click. Working on a notebok I have a) always a small screen and b) often no mouse attached. Thus I frequently have to scroll the DataTab, and if the mouse is not in the left part of the widget then some values may be changed inadvertently.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Unwanted Value Changes in Custom Widgets
I tried this in "InputField.cpp" and it didn't help. What did help was changing the "wheelEvent" handler to not accept events if the input field didn't already have focus.openBrain wrote: ↑Mon Jan 27, 2020 2:34 pm I don't know if it's enough, but we could change focus policy of the spin boxes with :Code: Select all
spinbox->setFocusPolicy(Qt::StrongFocus) #Default is Qt::WheelFocus which also accepts focus at wheel event
Have to check the other custom widgets and see if the same tweak works.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Unwanted Value Changes in Custom Widgets
This is my situation as well.chrisb wrote: ↑Mon Jan 27, 2020 9:45 pm I would appreciate the extra click. Working on a notebok I have a) always a small screen and b) often no mouse attached. Thus I frequently have to scroll the DataTab, and if the mouse is not in the left part of the widget then some values may be changed inadvertently.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Unwanted Value Changes in Custom Widgets
Here is an illustration of the current situation vs "how it should be". Excuse the video quality.
In the Preset widget you can clearly see values changes during scrolling using the current code. With proposed code the Preset widget is quite resistant to undesired changes.
In the Preset widget you can clearly see values changes during scrolling using the current code. With proposed code the Preset widget is quite resistant to undesired changes.
- Attachments
-
- ArchWindowNew.gif (318.13 KiB) Viewed 691 times
-
- ArchWindowCurrent.gif (234.48 KiB) Viewed 691 times
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Unwanted Value Changes in Custom Widgets
And here is a little write up of the proposed changes. Not that individual maintainer will have to decide if they want to use the new options or not.
-------------------------------------------------------------------------------
Proposed solution for preventing uncommanded value changes on scroll or
mouse wheel.
Fields treated with the following options require Tab or Click to receive focus,
and will not change values until they have focus. Once they have focus, the mouse
wheel can scroll the values up and down.
The behaviour of fields not treated with these option will be unchanged.
Usage of new options:
-------------------------------------------------------------------------------
Proposed solution for preventing uncommanded value changes on scroll or
mouse wheel.
Fields treated with the following options require Tab or Click to receive focus,
and will not change values until they have focus. Once they have focus, the mouse
wheel can scroll the values up and down.
The behaviour of fields not treated with these option will be unchanged.
Usage of new options:
Code: Select all
C++
#include <Gui/Widgets.h>
//regular Qt widgets
//sbScale is a QDoubleSpin box
ui->sbScale->installEventFilter(new Gui::WheelFilter(ui->sbScale));
//FC custom widgets
//ifInput is Gui::InputField
ui->ifInput->setWheelBlocker(true)
Python
# FreeCADGui.InputField
inField = ui.createWidget("Gui::InputField")
inField.setProperty("wheelBlocker", True)
# regular Qt Widgets
inCombo = QtGui.QComboBox()
WheelFilter(inCombo) #*** the WheelFilter class needs a home from which
#*** it can be imported or it can just be copy/pasted.
#*** It is < 20 lines of code, but it would be best
#*** from a maintenance perspective if the code was
#*** only in 1 place.