AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.43k stars 2.2k forks source link

Button does not accept clicks on its entire size #16179

Open CodeDevAM opened 3 months ago

CodeDevAM commented 3 months ago

Describe the bug

When a button has a big horizontal extend it has a relatively large area on the left and on the right where a click does not get accepted.

On mouse down the button shrinks and it seems to only accept clicks on mouse release on the shrinked button size.

https://github.com/AvaloniaUI/Avalonia/assets/125025268/2a3736bd-50f0-4d7b-ba9c-06e87c4905fb

To Reproduce

Should be reproducable with any large button but may depend on the theme and the styling.

Expected behavior

A button is accept clicks on its entire size

Avalonia version

11.1.0

OS

Windows

Additional context

No response

stevemonaco commented 3 months ago

This is because Fluent theme shrinks the Button while pressed and Button requires the pointer to be within its bounds upon release for a click event to occur.

The easiest way is to replace the shrinking behavior below via styling:

https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/Button.xaml#L51-L53

See https://github.com/AvaloniaUI/Avalonia/discussions/16100 for details.

CodeDevAM commented 3 months ago

Thanks for the advise.

However I would consider this as an unexpected behaviour. In my opinion the click logic of a button should work on the original size of the button when the mouse is pressed down. Because otherwise the UI do feel unresposive when you hit the button at the wrong place.

maxkatz6 commented 3 months ago

Probably a duplicate of https://github.com/AvaloniaUI/Avalonia/issues/7626