Skip to content

Commit c0f971a

Browse files
author
Julia Schwarz
committed
Mark events as used when slider consumes them, check for used before dispatching.
1 parent 30bbf94 commit c0f971a

File tree

1 file changed

+12
-3
lines changed
  • Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Sliders

1 file changed

+12
-3
lines changed

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Sliders/PinchSlider.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,18 @@ public void OnFocusExit(FocusEventData eventData)
181181

182182
public void OnPointerUp(MixedRealityPointerEventData eventData)
183183
{
184-
if (eventData.Pointer == activePointer)
184+
if (eventData.Pointer == activePointer && !eventData.used)
185185
{
186186
EndInteraction();
187+
188+
// Mark the pointer data as used to prevent other behaviors from handling input events
189+
eventData.Use();
187190
}
188191
}
189192

190193
public void OnPointerDown(MixedRealityPointerEventData eventData)
191194
{
192-
if (activePointer == null)
195+
if (activePointer == null && !eventData.used)
193196
{
194197
activePointer = eventData.Pointer;
195198
startSliderValue = sliderValue;
@@ -199,17 +202,23 @@ public void OnPointerDown(MixedRealityPointerEventData eventData)
199202
{
200203
OnInteractionStarted.Invoke(new SliderEventData(sliderValue, sliderValue, activePointer is IMixedRealityPointer));
201204
}
205+
206+
// Mark the pointer data as used to prevent other behaviors from handling input events
207+
eventData.Use();
202208
}
203209
}
204210

205211
public void OnPointerDragged(MixedRealityPointerEventData eventData)
206212
{
207-
if (eventData.Pointer == activePointer)
213+
if (eventData.Pointer == activePointer && !eventData.used)
208214
{
209215
var delta = activePointer.Position - startPointerPosition;
210216
var handDelta = Vector3.Dot(SliderTrackDirection.normalized, delta);
211217

212218
SliderValue = Mathf.Clamp(startSliderValue + handDelta / SliderTrackDirection.magnitude, 0, 1);
219+
220+
// Mark the pointer data as used to prevent other behaviors from handling input events
221+
eventData.Use();
213222
}
214223
}
215224
public void OnPointerClicked(MixedRealityPointerEventData eventData) { }

0 commit comments

Comments
 (0)