Browse Source
Merge pull request #11087 from AvaloniaUI/fixes/thumb-drag-delta
Make thumb drag delta relative to root.
pull/11091/head
Max Katz
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
5 additions and
5 deletions
-
src/Avalonia.Base/Input/PointerEventArgs.cs
-
src/Avalonia.Controls/Primitives/Thumb.cs
|
|
|
@ -77,14 +77,14 @@ namespace Avalonia.Input |
|
|
|
/// <summary>
|
|
|
|
/// Gets the pointer position relative to a control.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="relativeTo">The control.</param>
|
|
|
|
/// <param name="relativeTo">The visual whose coordinate system to use. Pass null for toplevel coordinate system</param>
|
|
|
|
/// <returns>The pointer position in the control's coordinates.</returns>
|
|
|
|
public Point GetPosition(Visual? relativeTo) => GetPosition(_rootVisualPosition, relativeTo); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the PointerPoint associated with the current event
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="relativeTo">The visual which coordinate system to use. Pass null for toplevel coordinate system</param>
|
|
|
|
/// <param name="relativeTo">The visual whose coordinate system to use. Pass null for toplevel coordinate system</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public PointerPoint GetCurrentPoint(Visual? relativeTo) |
|
|
|
=> new PointerPoint(Pointer, GetPosition(relativeTo), _properties); |
|
|
|
|
|
|
|
@ -85,7 +85,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
{ |
|
|
|
if (_lastPoint.HasValue) |
|
|
|
{ |
|
|
|
var point = e.GetPosition(this.GetVisualParent()); |
|
|
|
var point = e.GetPosition(null); |
|
|
|
var ev = new VectorEventArgs |
|
|
|
{ |
|
|
|
RoutedEvent = DragDeltaEvent, |
|
|
|
@ -100,7 +100,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
protected override void OnPointerPressed(PointerPressedEventArgs e) |
|
|
|
{ |
|
|
|
e.Handled = true; |
|
|
|
_lastPoint = e.GetPosition(this.GetVisualParent()); |
|
|
|
_lastPoint = e.GetPosition(null); |
|
|
|
|
|
|
|
var ev = new VectorEventArgs |
|
|
|
{ |
|
|
|
@ -123,7 +123,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
var ev = new VectorEventArgs |
|
|
|
{ |
|
|
|
RoutedEvent = DragCompletedEvent, |
|
|
|
Vector = (Vector)e.GetPosition(this.GetVisualParent()), |
|
|
|
Vector = (Vector)e.GetPosition(null), |
|
|
|
}; |
|
|
|
|
|
|
|
RaiseEvent(ev); |
|
|
|
|