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
- DownloadHandlerScript.CompleteContent is called twice when building for WebGL
- Scene view has Y coordinates of the Screen Position node flipped when some of the URP features are disabled
- Volumetric fog shader variants are missing from build when "Strict Shader Variant Matching" is disabled
- Unnecessary modifications clutter the Scene when using a RectTransform driven by a LayoutGroup in a Prefab
- Files in the target folder are deleted without a proper warning when building an iOS project
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.