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.
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
}
}
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?
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.