CommunityToolkit / CommunityToolkit/Maui

[BUG] TouchBehavior does not work on Button in Windows

Open
#2,538 0 comments 0 reactions 0 assignees View on GitHub
area/behaviors bug unverified
Dominant language
C#
Stars
2.7k
Forks
500
Avg merge
2d 14h
Merged PRs (30d)
7

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Did you read the "Reporting a bug" section on Contributing file?

- [x] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

### Current Behavior

_TouchBehavior_ does not seem to work on _Button_ controls in _Windows_. Works as expected on _Android_. _Command_ (short click/tap) and _LongPressCommand_ are nether one triggered when using _TouchBehavior_ on a _Button_. Moving the TouchBehavior definition up to a _Label_ (and changing it to a Label type obviously) works as expected on both platforms. Moving it to an _Image_ also works on both platforms. Moving it back to the _Button_ results in the short and long taps being registered on Android only, and not Windows.

### Expected Behavior

I expect that TouchBehavior (particularly Long Presses) work the same way across platforms.

### Steps To Reproduce

1. Open attached project (which is a File New project with the DotNet bot image and I added some TouchBehaviors).
2. Build and run Android version.
3. Observe that a quick tap and a LongPress works on the Button, the bottom Label, and the Image. Both TouchBehaviors work on all 3 controls on Android.
4. Build and run Windows version.
5. Observe that clicking the Label and the Image works as expected. Also observe that a LongPress (with the mouse click) also works as expected.
6. Observe that clicking the Button does not work, nor does a LongPress. Neither TouchBehavior works on the Button in Windows.

### Link to public reproduction project repository

https://github.com/TheInnoventor/LongPressTest

### Environment

```markdown
- .NET MAUI CommunityToolkit: 11.1.0
- OS: Windows 10
- .NET MAUI: 9.0.40
```

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.