Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,17 @@ protected override void OnPointerMoved(PointerEventArgs e)
{
base.OnPointerMoved(e);

var delta = e.GetPosition(this) - _mouseDownPosition;
var currentPoint = e.GetCurrentPoint(this);
var delta = currentPoint.Position - _mouseDownPosition;

if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed ||
var pointerSupportsDrag = currentPoint.Pointer.Type switch
{
PointerType.Mouse => currentPoint.Properties.IsLeftButtonPressed,
PointerType.Pen => currentPoint.Properties.IsRightButtonPressed,
_ => false
};

if (!pointerSupportsDrag ||
e.Handled ||
Math.Abs(delta.X) < DragDistance && Math.Abs(delta.Y) < DragDistance ||
_mouseDownPosition == s_InvalidPoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,19 @@ void ITreeDataGridSelectionInteraction.OnPointerPressed(TreeDataGrid sender, Poi
// Select a cell on pointer pressed if:
//
// - It's a mouse click, not touch: we don't want to select on touch scroll gesture start
// - It's a pen secondary button press, we don't want to select on primary button scroll gesture start
// - The cell isn't already selected: we don't want to deselect an existing multiple selection
// if the user is trying to drag multiple cells
//
// Otherwise select on pointer release.
var pointerSupportSelectionOnPress = e.Pointer.Type switch
{
PointerType.Mouse => true,
PointerType.Pen => e.GetCurrentPoint(null).Properties.IsRightButtonPressed,
_ => false
};
if (!e.Handled &&
e.Pointer.Type == PointerType.Mouse &&
pointerSupportSelectionOnPress &&
e.Source is Control source &&
sender.TryGetCell(source, out var cell) &&
!IsSelected(cell.ColumnIndex, cell.RowIndex))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,19 @@ void ITreeDataGridSelectionInteraction.OnPointerPressed(TreeDataGrid sender, Poi
// Select a row on pointer pressed if:
//
// - It's a mouse click, not touch: we don't want to select on touch scroll gesture start
// - It's a pen secondary button press, we don't want to select on primary button scroll gesture start
// - The row isn't already selected: we don't want to deselect an existing multiple selection
// if the user is trying to drag multiple rows
//
// Otherwise select on pointer release.
var pointerSupportSelectionOnPress = e.Pointer.Type switch
{
PointerType.Mouse => true,
PointerType.Pen => e.GetCurrentPoint(null).Properties.IsRightButtonPressed,
_ => false
};
if (!e.Handled &&
e.Pointer.Type == PointerType.Mouse &&
pointerSupportSelectionOnPress &&
e.Source is Control source &&
sender.TryGetRow(source, out var row) &&
_source.Rows.RowIndexToModelIndex(row.RowIndex) is { } modelIndex &&
Expand Down