Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit ddc7c05

Browse files
committed
fix
1 parent dcfa9fa commit ddc7c05

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

Runtime/engine/UIWidgetsPanel.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,15 @@ void handleMouseScroll() {
260260
}
261261

262262
int getMouseButtonDown() {
263+
//default mouse button key = left mouse button
264+
var defaultKey = 0;
263265
for (int key = 0; key < mouseButtonNum; key++) {
264266
if (Input.GetMouseButton(key)) {
265-
return InputUtils.getMouseButtonKey(key);
267+
defaultKey = key;
268+
break;
266269
}
267270
}
268-
269-
return 0;
271+
return InputUtils.getMouseButtonKey(defaultKey);
270272
}
271273

272274
public void OnPointerDown(PointerEventData eventData) {

Runtime/gestures/events.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ public PointerHoverEvent(
103103
position: position,
104104
down: false) {
105105
}
106+
107+
public static PointerHoverEvent fromHoverEvent(PointerEvent hover) {
108+
return new PointerHoverEvent(
109+
timeStamp: hover.timeStamp,
110+
pointer: hover.pointer,
111+
kind: hover.kind,
112+
device: hover.device,
113+
position: hover.position
114+
);
115+
}
106116
}
107117

108118
public class PointerEnterEvent : PointerEvent {
@@ -121,7 +131,7 @@ public PointerEnterEvent(
121131
down: false) {
122132
}
123133

124-
public static PointerEnterEvent fromHoverEvent(PointerHoverEvent hover) {
134+
public static PointerEnterEvent fromHoverEvent(PointerEvent hover) {
125135
return new PointerEnterEvent(
126136
timeStamp: hover.timeStamp,
127137
pointer: hover.pointer,

Runtime/gestures/mouse_tracking.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ void exitAllDevices(_TrackedAnnotation trackedAnnotation) {
171171
if (!hitAnnotation.activeDevices.Contains(deviceId)) {
172172
hitAnnotation.activeDevices.Add(deviceId);
173173
if (hitAnnotation.annotation?.onEnter != null) {
174-
hitAnnotation.annotation.onEnter(PointerEnterEvent.fromHoverEvent((PointerHoverEvent)lastEvent));
174+
hitAnnotation.annotation.onEnter(PointerEnterEvent.fromHoverEvent(lastEvent));
175175
}
176176
}
177177

178178
if (hitAnnotation.annotation?.onHover != null) {
179-
hitAnnotation.annotation.onHover((PointerHoverEvent)lastEvent);
179+
hitAnnotation.annotation.onHover(PointerHoverEvent.fromHoverEvent(lastEvent));
180180
}
181181

182182
foreach (_TrackedAnnotation trackedAnnotation in this._trackedAnnotations.Values) {

0 commit comments

Comments
 (0)