Search Issue Tracker
By Design
Votes
0
Found in
2018.3.0a1
2019.1.0a1
2019.1.0f2
2019.2.0a1
2019.3.0a1
Issue ID
1149053
Regression
No
MoveMouseEvent.button returns 0 both when no button is pressed and when the left mouse button is pressed
How to reproduce:
1. Open the attached "case_1149053-MouseMoveButton.zip" project
2. Open the "BugReport > ExampleWindow" window
3. Move the mouse around in the "Actual Behavior" box, notice that MoveMouseEvent.button returns 0
4. Move the mouse while holding the left mouse button around in the "Actual Behavior" box
5. Inspect the MoveMouseEvent.button return value
Expected results: MoveMouseEvent.button returns different values when moving the mouse with or without clicking the left mouse button
Actual results: MoveMouseEvent.button returns 0 both when moving with and without clicking the left mouse button
Reproducible with: 2018.3.14f1, 2019.1.1f1, 2019.2.0a14, 2019.3.0a1
Note: Could not test in 2017.4 due to missing namespace errors.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- UI Overlay Image gets darker on each Camera when multiple Cameras are used
- Assertion failed on expression: 'scriptedImporterClass == SCRIPTING_NULL error when opening the standalone profiler window
- Disabled assets in Import Unity Package window aren't tracked but count as being selected by user
- [Windows] Crash on GetManagerFromContext when video is playing and creating High Definition 3D Projects after FMOD failed to switch back to normal output Error appeared
- GC Alloc produced when adding items to MultiColumnListView with Auto Assign Binding
Resolution Note (2019.3.X):
Hello,
As of today this an expected behaviour and the issue is a shortcoming of our current API.
This comes from the fact that the "button" property reflects the native event "button" property for which "0" means left.
https://docs.unity3d.com/ScriptReference/Event-button.html
However UIElements translates both MouseDrag and MouseMove native event types to the same MouseMoveEvent object.
The "button" property is only meaningful for Drag events, so the suggested workaround to read the underlying native event type to detect a proper drag:
For example testing with "evt.imguiEvent.type == EventType.MouseDrag" will work.
https://docs.unity3d.com/ScriptReference/UIElements.EventBase-imguiEvent.html
In 2019.3 we will introduce a more usable API which will expose a bit mask to test for pressed buttons.
Thanks for reporting this issue, hopefully this will do for now.