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
- Foldout arrow indent is misaligned in the Inspector when used in Custom Type
- [Android] The Player screen turns black when playing a video under certain conditions
- Search window icons at the bottom are cut off when Search window is resized vertically
- "Try something else?" text label is cut off when searching for a long text in the Search window
- Rendering Debugger window sections do not have a minimum width set when resizing with the slider in the middle of the window
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.