118 lines
3.2 KiB
C#
118 lines
3.2 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
|
|
namespace UnityEngine.Experimental.UIElements
|
|
{
|
|
// Token: 0x0200030E RID: 782
|
|
public class Clickable : MouseManipulator
|
|
{
|
|
// Token: 0x060031FF RID: 12799 RVA: 0x0004A394 File Offset: 0x00048594
|
|
public Clickable(Action handler, long delay, long interval)
|
|
: this(handler)
|
|
{
|
|
this.m_Delay = delay;
|
|
this.m_Interval = interval;
|
|
}
|
|
|
|
// Token: 0x06003200 RID: 12800 RVA: 0x0004A3AC File Offset: 0x000485AC
|
|
public Clickable(Action handler)
|
|
{
|
|
this.clicked = handler;
|
|
base.activators.Add(new ManipulatorActivationFilter
|
|
{
|
|
button = MouseButton.LeftMouse
|
|
});
|
|
}
|
|
|
|
// Token: 0x14000026 RID: 38
|
|
// (add) Token: 0x06003201 RID: 12801 RVA: 0x0004A3E4 File Offset: 0x000485E4
|
|
// (remove) Token: 0x06003202 RID: 12802 RVA: 0x0004A41C File Offset: 0x0004861C
|
|
[field: DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|
public event Action clicked;
|
|
|
|
// Token: 0x17000B56 RID: 2902
|
|
// (get) Token: 0x06003203 RID: 12803 RVA: 0x0004A454 File Offset: 0x00048654
|
|
// (set) Token: 0x06003204 RID: 12804 RVA: 0x0004A470 File Offset: 0x00048670
|
|
public Vector2 lastMousePosition { get; private set; }
|
|
|
|
// Token: 0x06003205 RID: 12805 RVA: 0x0004A47C File Offset: 0x0004867C
|
|
private void OnTimer(TimerState timerState)
|
|
{
|
|
if (this.clicked != null && this.IsRepeatable())
|
|
{
|
|
if (base.target.ContainsPointToLocal(this.lastMousePosition))
|
|
{
|
|
this.clicked();
|
|
base.target.pseudoStates |= PseudoStates.Active;
|
|
}
|
|
else
|
|
{
|
|
base.target.pseudoStates &= ~PseudoStates.Active;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x06003206 RID: 12806 RVA: 0x0004A4F4 File Offset: 0x000486F4
|
|
private bool IsRepeatable()
|
|
{
|
|
return this.m_Delay > 0L || this.m_Interval > 0L;
|
|
}
|
|
|
|
// Token: 0x06003207 RID: 12807 RVA: 0x0004A524 File Offset: 0x00048724
|
|
public override EventPropagation HandleEvent(Event evt, VisualElement finalTarget)
|
|
{
|
|
EventType type = evt.type;
|
|
if (type != EventType.MouseDown)
|
|
{
|
|
if (type != EventType.MouseUp)
|
|
{
|
|
if (type == EventType.MouseDrag)
|
|
{
|
|
if (this.HasCapture())
|
|
{
|
|
this.lastMousePosition = evt.mousePosition;
|
|
return EventPropagation.Stop;
|
|
}
|
|
}
|
|
}
|
|
else if (base.CanStopManipulation(evt))
|
|
{
|
|
this.ReleaseCapture();
|
|
if (this.IsRepeatable())
|
|
{
|
|
base.target.Unschedule(new Action<TimerState>(this.OnTimer));
|
|
}
|
|
else if (this.clicked != null && base.target.ContainsPointToLocal(evt.mousePosition))
|
|
{
|
|
this.clicked();
|
|
}
|
|
base.target.pseudoStates &= ~PseudoStates.Active;
|
|
return EventPropagation.Stop;
|
|
}
|
|
}
|
|
else if (base.CanStartManipulation(evt))
|
|
{
|
|
this.TakeCapture();
|
|
this.lastMousePosition = evt.mousePosition;
|
|
if (this.IsRepeatable())
|
|
{
|
|
if (this.clicked != null && base.target.ContainsPointToLocal(evt.mousePosition))
|
|
{
|
|
this.clicked();
|
|
}
|
|
this.Schedule(new Action<TimerState>(this.OnTimer)).StartingIn(this.m_Delay).Every(this.m_Interval);
|
|
}
|
|
base.target.pseudoStates |= PseudoStates.Active;
|
|
return EventPropagation.Stop;
|
|
}
|
|
return EventPropagation.Continue;
|
|
}
|
|
|
|
// Token: 0x04000A14 RID: 2580
|
|
private readonly long m_Delay;
|
|
|
|
// Token: 0x04000A15 RID: 2581
|
|
private readonly long m_Interval;
|
|
}
|
|
}
|