Skip to content

Inconsistent and hardcoded behaviour when tapping selectable items #18902

@TomEdwardsEnscape

Description

@TomEdwardsEnscape

Describe the bug

Selection with a touch device has been implemented in different ways for different controls.

  • ListBoxItem will select on touch release, as long as the touch ended within IPlatformSettings.GetTapSize pixels of its start point (even if the touch moved away and then came back)
  • TabItem will select on touch release, as long as the pointer didn't leave the item's header during the touch
  • TreeViewItem will select on touch begin

It is not possible to change any of this without creating a derived type and overriding its class event handler methods.

To Reproduce

Tap a ListBoxItem, TabItem, and TreeViewItem with a touch device (or hack Avalonia so that a mouse pointer event leads to the touch device code).

Ideally remove any scroll viewers before testing, as these by default include a scroll gesture recogniser which can swallow input events and disrupt results.

Expected behavior

All three items should by default have the same behaviour. From experimenting with my devices, I can come up with three rules:

  1. Pressed effect when a touch begins
  2. Pressed effect removed when a gesture begins (e.g. scrolling)
  3. Item selected on touch release anywhere over the item, unless another gesture began

But one size doesn't fit all, so this behaviour should be customisable from the outside, without creating a derived class and overriding protected methods.

Avalonia version

11.3

OS

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions