PointerDown event not triggering when holding another button down (2022.3)

Reproducible in 2022.3 (Runtime only, works as expected in editor)
Not reproducible in 6 (no backport?)

RegisterCallback<PointerDownEvent> on any VisualElement
Press and hold left mouse on element
Right click the element
Result: right click ignored

same thing happens if buttons are inversed (hold right, left click)
same thing happens for MouseDownEvent

Please use Help - Report a Bug in the editor if you haven’t done so. Discussions is not for bug reports unless you are also looking for additional feedback, workarounds, and similar.

1 Like

Would be happy if there was a workaround for this

Hello! This discussion is about a similar problem, let me know if it helps: Detecting right mouse down while holding a left mouse button

It doesn’t help because there is no solution there

Hey, a workaround, depending on your desired behaviour, is using the OnMouseMove event and reading the pressedButtons from there. For example, in the other thread where they are dragging an item…

void OnMouseMove(MouseMoveEvent evt)
    {
        if (!isDragging) return;

        UpdateDraggedPosition(evt.mousePosition);

        //3 is right mouse button
        if (evt.pressedButtons == 3)
        {
            //do stuff
        }
    }

Try this out and let me know the results.

@raymondyunity

The workaround doesn’t work

We’re going to need more details. Please report a bug and we can look into it.

I will submit a bug report

All the details are here:
Add this to any element
RegisterCallback<MouseDownEvent>(e => Debug.Log("mouse down"));
Hold any mouse button down, press another mouse button → no debug message

Received the bug. I’m curious why the MouseMoveEvent solution does not work for your project? If you can explain a bit more then I’m sure we can find a solution for your case.

As for this bug, this behaviour is by design. That second MouseDownEvent will not trigger but a MouseMoveEvent will. We try to follow W3C standards (Pointer Events) and in this case it is advisable to read the value on the Button property. We also recognize that it is unintuitive.

You can also use the EventDebugger to further debug events when trying different input events.

Unintuitive is an understatement.
I tried the workaround once again and it indeed works, the event is triggered multiple times but at least it’s something. I’m curious why it works “as expected” in Unity 6 though… do you not follow the W3C standards there?

Glad the workaround worked in your case.

In Unity6, there was a refactor to improve this scenario. So it still follows the standard since the PointerMoveEvent will still be triggered with Buttons=3 but the MouseDownEvents are also called.

So in the event debugger (Experimental in U6) you will see:

PointerMoveEvent {Buttons=3}
MouseDownEvent

However, we will not be back-porting this improvement to 2022.3 at this time.

Got it,
Thank you for your time!