Kiwano Engine v1.3.x
MouseEvent.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/platform/Keys.h>
23#include <kiwano/event/Event.h>
24#include <kiwano/math/Math.h>
25
26namespace kiwano
27{
28
36class KGE_API MouseEvent : public Event
37{
38public:
40
41 MouseEvent(const EventType& type);
42};
43
46class KGE_API MouseMoveEvent : public MouseEvent
47{
48public:
50};
51
54class KGE_API MouseDownEvent : public MouseEvent
55{
56public:
57 MouseButton button;
58
60};
61
64class KGE_API MouseUpEvent : public MouseEvent
65{
66public:
67 MouseButton button;
68
70};
71
74class KGE_API MouseClickEvent : public MouseEvent
75{
76public:
77 MouseButton button;
78
80};
81
84class KGE_API MouseHoverEvent : public MouseEvent
85{
86public:
88};
89
92class KGE_API MouseOutEvent : public MouseEvent
93{
94public:
96};
97
100class KGE_API MouseWheelEvent : public MouseEvent
101{
102public:
103 float wheel;
104
106};
107
108template <>
110{
111 inline bool operator()(const Event* evt) const
112 {
113 return evt->GetType() == KGE_EVENT(MouseMoveEvent) || evt->GetType() == KGE_EVENT(MouseDownEvent)
114 || evt->GetType() == KGE_EVENT(MouseUpEvent) || evt->GetType() == KGE_EVENT(MouseClickEvent)
115 || evt->GetType() == KGE_EVENT(MouseHoverEvent) || evt->GetType() == KGE_EVENT(MouseOutEvent)
116 || evt->GetType() == KGE_EVENT(MouseWheelEvent);
117 }
118};
119
122} // namespace kiwano
事件类型
Definition: EventType.h:36
事件
Definition: Event.h:43
const EventType & GetType() const
获取类型事件
Definition: Event.h:91
鼠标点击事件
Definition: MouseEvent.h:75
MouseButton button
鼠标键值
Definition: MouseEvent.h:77
鼠标按键按下事件
Definition: MouseEvent.h:55
MouseButton button
鼠标键值
Definition: MouseEvent.h:57
鼠标事件
Definition: MouseEvent.h:37
Point pos
鼠标位置
Definition: MouseEvent.h:39
鼠标移入事件
Definition: MouseEvent.h:85
鼠标移动事件
Definition: MouseEvent.h:47
鼠标移出事件
Definition: MouseEvent.h:93
鼠标按键抬起事件
Definition: MouseEvent.h:65
MouseButton button
鼠标键值
Definition: MouseEvent.h:67
鼠标滚轮事件
Definition: MouseEvent.h:101
float wheel
滚轮值
Definition: MouseEvent.h:103
事件特性:判断事件类型是否相同
Definition: Event.h:81