Skip to content

MouseEvent/MouseClick can't be externally controlled - was Slider does not seem to respect click handlers #3714

@tznind

Description

@tznind

Describe the bug
Not sure exactly what is going on but I am trying to stop clicks going through to SliderView in TGD. This approach seems to work for other views.

I tried looking at gui.cs\UnitTests\Views\SliderTests.cs` for mouse tests but couldn't see any to adapt for repro.

if (subView.GetType().IsGenericType(typeof(Slider<>)))
{
    // TODO: Does not seem to work
    subView.MouseEvent += (s, e) => SuppressNativeClickEvents(s, e,true);
    subView.MouseClick += (s, e) => SuppressNativeClickEvents(s,e, true);
}

...

private void SuppressNativeClickEvents(object? sender, MouseEventEventArgs obj, bool alsoSuppressClick = false)
{
    if (alsoSuppressClick)
    {
        obj.Handled = true;
    }
    else
    {
        // Suppress everything except single click (selection)
        obj.Handled = obj.MouseEvent.Flags != MouseFlags.Button1Clicked;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions