Skip to content

Commit 9c137dc

Browse files
author
Julia Schwarz
committed
Replace IsNear field in SliderEventData with more general Pointer field
- Pointer field can be used to determine if the right or left hand is hovering the slider - Also, pointer can be used to determine if the interaction is near or far via pointer is IMixedRealityNearPointer
1 parent 3590d89 commit 9c137dc

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public float SliderValue
3232
var oldSliderValue = sliderValue;
3333
sliderValue = value;
3434
UpdateUI();
35-
OnValueUpdated.Invoke(new SliderEventData(oldSliderValue, value, activePointer is IMixedRealityPointer, this));
35+
OnValueUpdated.Invoke(new SliderEventData(oldSliderValue, value, activePointer, this));
3636
}
3737
}
3838

@@ -134,7 +134,7 @@ public void Start()
134134
sliderThumbOffset = thumbRoot.transform.position - thumbProjectedOnTrack;
135135

136136
UpdateUI();
137-
OnValueUpdated.Invoke(new SliderEventData(sliderValue, sliderValue, false, this));
137+
OnValueUpdated.Invoke(new SliderEventData(sliderValue, sliderValue, null, this));
138138
}
139139

140140
private void OnDisable()
@@ -172,7 +172,7 @@ private void EndInteraction()
172172
{
173173
if (OnInteractionEnded != null)
174174
{
175-
OnInteractionEnded.Invoke(new SliderEventData(sliderValue, sliderValue, activePointer is IMixedRealityPointer, this));
175+
OnInteractionEnded.Invoke(new SliderEventData(sliderValue, sliderValue, activePointer, this));
176176
}
177177
activePointer = null;
178178
}
@@ -182,12 +182,12 @@ private void EndInteraction()
182182
#region IMixedRealityFocusHandler
183183
public void OnFocusEnter(FocusEventData eventData)
184184
{
185-
OnHoverEntered.Invoke(new SliderEventData(sliderValue, sliderValue, eventData.Pointer is IMixedRealityNearPointer, this));
185+
OnHoverEntered.Invoke(new SliderEventData(sliderValue, sliderValue, eventData.Pointer, this));
186186
}
187187

188188
public void OnFocusExit(FocusEventData eventData)
189189
{
190-
OnHoverExited.Invoke(new SliderEventData(sliderValue, sliderValue, eventData.Pointer is IMixedRealityNearPointer, this));
190+
OnHoverExited.Invoke(new SliderEventData(sliderValue, sliderValue, eventData.Pointer, this));
191191
}
192192
#endregion
193193

@@ -214,7 +214,7 @@ public void OnPointerDown(MixedRealityPointerEventData eventData)
214214
startSliderPosition = gameObject.transform.position;
215215
if (OnInteractionStarted != null)
216216
{
217-
OnInteractionStarted.Invoke(new SliderEventData(sliderValue, sliderValue, activePointer is IMixedRealityPointer, this));
217+
OnInteractionStarted.Invoke(new SliderEventData(sliderValue, sliderValue, activePointer, this));
218218
}
219219

220220
// Mark the pointer data as used to prevent other behaviors from handling input events

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
// Copyright (c) Microsoft Corporation. All rights reserved.
33
// Licensed under the MIT License. See LICENSE in the project root for license information.
44
//
5+
using Microsoft.MixedReality.Toolkit.Input;
6+
57
namespace Microsoft.MixedReality.Toolkit.UI
68
{
79
public class SliderEventData
810
{
9-
public SliderEventData(float o, float n, bool isNear, PinchSlider slider)
11+
public SliderEventData(float o, float n, IMixedRealityPointer pointer, PinchSlider slider)
1012
{
1113
OldValue = o;
1214
NewValue = n;
13-
IsNear = isNear;
15+
Pointer = pointer;
1416
Slider = slider;
1517
}
1618

@@ -30,8 +32,9 @@ public SliderEventData(float o, float n, bool isNear, PinchSlider slider)
3032
public PinchSlider Slider { get; private set; }
3133

3234
/// <summary>
33-
/// Whether the slider is being interacted near or at a distance.
35+
/// The currently active pointer manipulating / hovering the slider,
36+
/// or null if no pointer is manipulating the slider
3437
/// </summary>
35-
public bool IsNear { get; set; }
38+
public IMixedRealityPointer Pointer { get; set; }
3639
}
3740
}

0 commit comments

Comments
 (0)