Prevent mouse wheel scroll on entry edit username field#12398
Prevent mouse wheel scroll on entry edit username field#12398droidmonkey merged 2 commits intodevelopfrom
Conversation
* Reported by shawnkhu via Matrix
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where mouse wheel scrolling would change the username field value in the entry edit dialog even when the field was not focused. The solution involves moving a reusable MouseWheelEventFilter class from ApplicationSettingsWidget to GuiTools.h and applying it to the username combo box.
Key changes:
- Moved MouseWheelEventFilter from ApplicationSettingsWidget to GuiTools.h for reusability
- Applied the event filter to the username combo box in EditEntryWidget
- Set StrongFocus policy on the username combo box to ensure proper focus behavior
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/gui/GuiTools.h | Added MouseWheelEventFilter class definition for preventing wheel events on unfocused widgets |
| src/gui/entry/EditEntryWidget.cpp | Applied MouseWheelEventFilter to username combo box and added GuiTools.h include |
| src/gui/entry/EditEntryWidgetMain.ui | Set focusPolicy to StrongFocus for username combo box |
| src/gui/ApplicationSettingsWidget.cpp | Removed duplicate MouseWheelEventFilter class and added GuiTools.h include |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #12398 +/- ##
===========================================
- Coverage 64.19% 64.19% -0.00%
===========================================
Files 376 377 +1
Lines 39371 39373 +2
===========================================
+ Hits 25273 25274 +1
- Misses 14098 14099 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
This does not work for me. At least in macOS when you hover in the username combobox and use mouse wheel, Qt sends first FocusIn event and Wheel event after that. So the combobox is actually focused right before using the mouse wheel.
One possible solution would be to catch the focus only when mouse button is used (basically losing the focus if click is not used):
bool eventFilter(QObject* obj, QEvent* event) override
{
auto* widget = qobject_cast<QWidget*>(obj);
if (event->type() == QEvent::FocusIn && widget && !(QApplication::mouseButtons() & Qt::LeftButton)) {
widget->clearFocus();
event->ignore();
return true;
}
if (event->type() == QEvent::Wheel && widget && !widget->hasFocus()) {
event->ignore();
return true;
}
return QObject::eventFilter(obj, event);
}
However, this is is just a pseudo-code because it breaks focusing with Tab.
|
@varjolintu fixed it |
It works now. Strange that it was not enough to define it to the .ui file. |
|
The line edit is created after you enable editing, for some reason it is given wheel focus on macos when it is created. 🤷♂️ |
…ot#12398) * Reported by shawnkhu via Matrix, thank you!
…ot#12398) * Reported by shawnkhu via Matrix, thank you!
…ot#12398) * Reported by shawnkhu via Matrix, thank you!
* Reported by shawnkhu via Matrix, thank you!
Release 2.7.11 (2025-11-23) - Add image, HTML, Markdown preview, and text editing support to inline attachment viewer [keepassxreboot#12085, keepassxreboot#12244, keepassxreboot#12654] - Add database merge confirmation dialog [keepassxreboot#10173] - Add option to auto-generate a password for new entries [keepassxreboot#12593] - Add support for group sync in KeeShare [keepassxreboot#11593] - Add {UUID} placeholder for use in references [keepassxreboot#12511] - Add “Wait for Enter” search option [keepassxreboot#12263] - Add keyboard shortcut to “Jump to Group” from search results [keepassxreboot#12225] - Add predefined search for TOTP entries [keepassxreboot#12199] - Add confirmation when closing database via ESC key [keepassxreboot#11963] - Add support for escaping placeholder expressions [keepassxreboot#11904] - Reduce tab indentation width in notes fields [keepassxreboot#11919] - Cap default Argon2 parallelism when creating a new database [keepassxreboot#11853] - Database lock after inactivity now enabled by default and set to 900 seconds [keepassxreboot#12689, keepassxreboot#12609] - Copying TOTP now opens setup dialog if none is configured for entry [keepassxreboot#12584] - Make double click action configurable [keepassxreboot#12322] - Remove unused “Last Accessed” from GUI [keepassxreboot#12602] - Auto-Type: Add more granular confirmation settings [keepassxreboot#12370] - Auto-Type: Add URL typing preset and add copy options to menu [keepassxreboot#12341] - Browser: Do not allow sites automatically if entry added from browser extension [keepassxreboot#12413] - Browser: Add options to restrict exposed groups [keepassxreboot#9852, keepassxreboot#12119] - Bitwarden Import: Add support for timestamps and password history [keepassxreboot#12588] - macOS: Add Liquid Glass icon [keepassxreboot#12642] - macOS: Remove theme-based menubar icon toggle [keepassxreboot#12685] - macOS: Add Window and Help menus [keepassxreboot#12357] - Windows: Add option to add KeePassXC to PATH during installation [keepassxreboot#12171] - Fix window geometry not being restored properly when KeePassXC starts in tray [keepassxreboot#12683] - Fix potential database truncation when using direct write save method with YubiKeys [keepassxreboot#11841] - Fix issue with database backup saving [keepassxreboot#11874] - Fix UI lockups during startup with multiple tabs [keepassxreboot#12053] - Fix keyboard shortcuts when menubar is hidden [keepassxreboot#12431] - Fix clipboard being cleared on exit even if no password was copied [keepassxreboot#12603] - Fix single-instance detection when username contains invalid filename characters [keepassxreboot#12559] - Fix “Search Wait for Enter” setting not being save [keepassxreboot#12614] - Fix hotkey accelerators not being escaped properly on database tabs [keepassxreboot#12630] - Fix confusing error if user cancels out of key file edit dialog [keepassxreboot#12639] - Fix issues with saved searches and “Press Enter to Search” option [keepassxreboot#12314] - Fix URL wildcard matching [keepassxreboot#12257] - Fix TOTP visibility on unlock and settings change [keepassxreboot#12220] - Fix KeeShare entries with reference attributes not updating [keepassxreboot#11809] - Fix sort order not being maintained when toggling filters in database reports [keepassxreboot#11849] - Fix several UI font and layout issues [keepassxreboot#11967, keepassxreboot#12102] - Prevent mouse wheel scroll on edit username field [keepassxreboot#12398] - Improve base translation consistency [keepassxreboot#12432] - Improve inactivity timer [keepassxreboot#12246] - Documentation improvements [keepassxreboot#12373, keepassxreboot#12506] - Browser: Fix ordering of clientDataJSON in Passkey response object [keepassxreboot#12120] - Browser: Fix URL matching for additional URLs [keepassxreboot#12196] - Browser: Fix group settings inheritance [keepassxreboot#12368] - Browser: Allow read-only native messaging config files [keepassxreboot#12236] - Browser: Optimise entry iteration in browser access control dialog [keepassxreboot#11817] - Browser: Fix “Do not ask permission for HTTP Basic Auth” option [keepassxreboot#11871] - Browser: Fix native messaging path for Tor Browser launcher on Linux [keepassxreboot#12005] - Auto-Type: Fix empty window behaviour [keepassxreboot#12622] - Auto-Type: Take delays into account when typing TOTP [keepassxreboot#12691] - SSH Agent: Fix out-of-memory crash with malformed SSH keys [keepassxreboot#12606] - CSV Import: Fix modified and creation time import [keepassxreboot#12379] - CSV Import: Fix duplication of root groups on import [keepassxreboot#12240] - Proton Pass Import: Fix email addresses not being imported when no username set [keepassxreboot#11888] - macOS: Fix secure input getting stuck [keepassxreboot#11928] - Windows: Prevent launch as SYSTEM user from MSI installer [keepassxreboot#12705] - Windows: Remove broken check for MSVC Redistributable from MSI installer [keepassxreboot#11950] - Linux: Fix startup delay due to StartupNotify setting in desktop file [keepassxreboot#12306] - Linux: Fix memory initialisation when --pw-stdin is used with a pipe [keepassxreboot#12050]
Testing strategy
Tested locally
Type of change