Skip to content

Commit b3e29e5

Browse files
committed
Let a wheel route from a fixed element
- WindowInputRouter.MouseWheel gains an internal overload that starts the bubble at a given element instead of the one under the point, and returns the element that handled it - A pointer gesture that scrolls needs to stay with one scrollable: routing by point every time hands the gesture to whatever the scrolling brings under it
1 parent aff2815 commit b3e29e5

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

src/MewUI/Input/WindowInputRouter.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,45 @@ public static void MouseWheel(
235235
bool rightDown = false,
236236
bool middleDown = false,
237237
ModifierKeys modifiers = ModifierKeys.None)
238+
=> MouseWheel(window, positionInWindow, screenPosition, delta, leftDown, rightDown, middleDown, modifiers,
239+
routeFrom: null);
240+
241+
/// <summary>
242+
/// Routes wheel movement, starting the bubble at <paramref name="routeFrom"/> instead of the element
243+
/// under the point, and returns the element that handled it.
244+
/// </summary>
245+
internal static UIElement? MouseWheel(
246+
Window window,
247+
Point positionInWindow,
248+
Point screenPosition,
249+
Vector delta,
250+
bool leftDown,
251+
bool rightDown,
252+
bool middleDown,
253+
ModifierKeys modifiers,
254+
UIElement? routeFrom)
238255
{
239256
positionInWindow = window.SurfacePointToVisualTree(positionInWindow);
240257
window.UpdateLastMousePosition(positionInWindow, screenPosition);
241258

242-
var element = window.HitTest(positionInWindow);
259+
var element = routeFrom ?? window.HitTest(positionInWindow);
243260
var args = new MouseWheelEventArgs(positionInWindow, screenPosition, delta, leftDown, rightDown, middleDown, modifiers)
244261
{
245262
OriginalSource = element,
246263
Source = element,
247264
};
248265

249-
for (var current = element; current != null && !args.Handled; current = GetInputBubbleParent(window, current))
266+
for (var current = element; current != null; current = GetInputBubbleParent(window, current))
250267
{
251268
args.Source = current;
252269
current.RaiseMouseWheel(args);
270+
if (args.Handled)
271+
{
272+
return current;
273+
}
253274
}
275+
276+
return null;
254277
}
255278

256279
/// <summary>

0 commit comments

Comments
 (0)