kikipoulet / SukiUI

UI Theme for AvaloniaUI
MIT License
1.49k stars 139 forks source link

[Bug] SukiSideMenuItem does not support touch input #333

Open sdijoseph opened 3 days ago

sdijoseph commented 3 days ago

Check the following items

Description of the issue

SukiSideMenuItem does not support input from touchscreens. I believe this is due to the incomplete OnPointerPressed method that was mostly copied from ListBoxItem, and then the absence of OnPointerReleased. I can try to provide a PR with a fix, unless you have another way you want to resolve it.

    protected override void OnPointerPressed(PointerPressedEventArgs e)
    {
        base.OnPointerPressed(e);
        if (e.Handled)
            return;

        if (!e.Handled && ItemsControl.ItemsControlFromItemContainer(this) is SukiSideMenu owner)
        {
            var p = e.GetCurrentPoint(this);

            if (p.Properties.PointerUpdateKind is PointerUpdateKind.LeftButtonPressed or
                PointerUpdateKind.RightButtonPressed)
            {
                if (p.Pointer.Type == PointerType.Mouse)
                {
                    // If the pressed point comes from a mouse, perform the selection immediately.
                    e.Handled = owner.UpdateSelectionFromPointerEvent(this);
                }
            }
        }
    }

Package Version

6.0.0-rc

Environment

Windows 10

Expected Behavior

Touching a SukiSideMenuItem on a touchscreen should register like a mouse click does.

Reproduction

Try to touch a SukiSideMenuItem using a touchscreen.

Additional Information

No response

sirdoombox commented 1 day ago

I don't have any touch devices around to test this one properly, nor am I really sure how I would be able to mock that sort of input, I'd be much happier accepting a PR from someone has the device to ensure it's working as intended.

As long as the PR doesn't break any existing functionality on our side then I'd accept it essentially as-is.