summaryrefslogtreecommitdiff
path: root/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIInputHandler.cs
blob: 7086fca5b0c0e96e5c9a08fc45722e22dd40df29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using UnityEngine;
using UnityEngine.EventSystems;

public class UIInputHandler : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler
{
	public Action<UIInputHandler> m_onLeftClick;

	public Action<UIInputHandler> m_onLeftDown;

	public Action<UIInputHandler> m_onLeftUp;

	public Action<UIInputHandler> m_onRightClick;

	public Action<UIInputHandler> m_onRightDown;

	public Action<UIInputHandler> m_onRightUp;

	public Action<UIInputHandler> m_onMiddleClick;

	public Action<UIInputHandler> m_onMiddleDown;

	public Action<UIInputHandler> m_onMiddleUp;

	public Action<UIInputHandler> m_onPointerEnter;

	public Action<UIInputHandler> m_onPointerExit;

	public void OnPointerDown(PointerEventData eventData)
	{
		if (eventData.button == PointerEventData.InputButton.Right)
		{
			if (m_onRightDown != null)
			{
				m_onRightDown(this);
			}
		}
		else if (eventData.button == PointerEventData.InputButton.Left)
		{
			if (m_onLeftDown != null)
			{
				m_onLeftDown(this);
			}
		}
		else if (eventData.button == PointerEventData.InputButton.Middle && m_onMiddleDown != null)
		{
			m_onMiddleDown(this);
		}
	}

	public void OnPointerUp(PointerEventData eventData)
	{
		if (eventData.button == PointerEventData.InputButton.Right)
		{
			if (m_onRightUp != null)
			{
				m_onRightUp(this);
			}
		}
		else if (eventData.button == PointerEventData.InputButton.Left)
		{
			if (m_onLeftUp != null)
			{
				m_onLeftUp(this);
			}
		}
		else if (eventData.button == PointerEventData.InputButton.Middle && m_onMiddleUp != null)
		{
			m_onMiddleUp(this);
		}
	}

	public void OnPointerClick(PointerEventData eventData)
	{
		if (eventData.button == PointerEventData.InputButton.Right)
		{
			if (m_onRightClick != null)
			{
				m_onRightClick(this);
			}
		}
		else if (eventData.button == PointerEventData.InputButton.Left)
		{
			if (m_onLeftClick != null)
			{
				m_onLeftClick(this);
			}
		}
		else if (eventData.button == PointerEventData.InputButton.Middle && m_onMiddleClick != null)
		{
			m_onMiddleClick(this);
		}
	}

	public void OnPointerEnter(PointerEventData eventData)
	{
		if (m_onPointerEnter != null)
		{
			m_onPointerEnter(this);
		}
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		if (m_onPointerExit != null)
		{
			m_onPointerExit(this);
		}
	}
}