LT-22452 - fix mouse scrolling on date field in lex edit#754
LT-22452 - fix mouse scrolling on date field in lex edit#754johnml1135 wants to merge 5 commits intomainfrom
Conversation
NUnit Tests 1 files 1 suites 5m 42s ⏱️ Results for commit 7ac2ac0. ♻️ This comment has been updated with latest results. |
jasonleenaylor
left a comment
There was a problem hiding this comment.
It looks like this test adds another test that pops up a window while it is running. I was hoping to get away from that, I'd rather not have a unit test for this if that is the case.
@jasonleenaylor reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 3 files reviewed, all discussions resolved.
There was a problem hiding this comment.
Pull request overview
Adds an application-level IMessageFilter to ensure DataTree scrolls when the mouse wheel is used over child controls that consume WM_MOUSEWHEEL (e.g., RichTextBox inside DateSlice), and introduces configuration stubs in Serena project settings.
Changes:
- Register/unregister a static
WheelRedirectorto interceptWM_MOUSEWHEELand updateDataTree.AutoScrollPosition. - Add
WheelRedirectorinner class implementingIMessageFilterto redirect wheel scrolling based on cursor location. - Extend
.serena/project.ymlwith additional (currently unset) configuration keys.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Src/Common/Controls/DetailControls/DataTree.cs | Installs a message filter to redirect mouse-wheel scrolling to DataTree regardless of focused child control. |
| .serena/project.yml | Adds new Serena configuration keys for line endings and read-only memory patterns. |
Comments suppressed due to low confidence (1)
Src/Common/Controls/DetailControls/DataTree.cs:1
Unregister()is called unconditionally, including whendisposing == false(finalizer path). SinceApplication.Add/RemoveMessageFilteris thread-affine (per-UI-thread message loop), attempting to remove the filter from a non-UI/finalizer thread may not actually remove it (leaking the filter/list entry) and can introduce cross-thread issues. Move thes_wheelRedirector.Unregister(this);call inside theif (disposing)block (or otherwise ensure it executes on the same UI thread that performedRegister).
// Copyright (c) 2015-2017 SIL International
|
@jasonleenaylor - I removed the test. It doesn't really need a test, I was just trying to replicate it. It's hard to replicate without a full test. That is another PR (getting true no-popup testing). |
JIRA Explanation for LT-22452
Problem:
Mouse wheel scrolling does not work in the Lexicon Editor when the cursor is over the Date field (and potentially other non-ButtonLauncher controls in the DataTree).
Root Cause:
The Date field (
DateSlicein BasicTypeSlices.cs) wraps aRichTextBoxset toReadOnlywithBorderStyle.None.RichTextBoxinherits fromScrollableControland has internal scroll machinery that consumesWM_MOUSEWHEELmessages without propagating them to the parentDataTree. Win32 deliversWM_MOUSEWHEELto the focused window handle (theRichTextBox), so the message never reachesDataTreeand itsAutoScrollPositionproperty is never updated — the pane doesn't scroll.This is a general WinForms problem: any child control that internally handles
WM_MOUSEWHEEL(e.g.RichTextBox,ListView,TreeView) will swallow the mouse wheel and prevent its container from scrolling.Fix:
Added a
WheelRedirectorinner class toDataTreethat implementsIMessageFilter— a .NET/WinForms mechanism that intercepts Windows messages at the application message pump before they are dispatched to any window. This is the same pattern used in 7 other places in the FieldWorks codebase (e.g.FwFindReplaceDlg,SimpleRootSite,FwApp).When
WM_MOUSEWHEELis intercepted, the filter checks whether the cursor is over any liveDataTreeinstance. If so, it calculates the new scroll position using the sameAutoScrollPosition/AutoScrollMinSizeAPI thatDataTreeitself uses, applies it, and marks the message as handled. This ensures consistent scrolling regardless of which child control has focus.Changes:
WheelRedirectorinner class (~65 lines),Register()call in constructor,Unregister()call inDispose.Made changes.
This change is