Kiwano Engine v1.3.x
KeyEvent.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
25namespace kiwano
26{
27
35class KGE_API KeyEvent : public Event
36{
37public:
38 KeyEvent(const EventType& type);
39};
40
43class KGE_API KeyDownEvent : public KeyEvent
44{
45public:
46 KeyCode code;
47
49};
50
53class KGE_API KeyUpEvent : public KeyEvent
54{
55public:
56 KeyCode code;
57
58 KeyUpEvent();
59};
60
63class KGE_API KeyCharEvent : public KeyEvent
64{
65public:
66 char value;
67
69};
70
73class KGE_API IMEInputEvent : public KeyEvent
74{
75public:
76 String value;
77
79};
80
81template <>
83{
84 inline bool operator()(const Event* evt) const
85 {
86 return evt->GetType() == KGE_EVENT(KeyDownEvent) || evt->GetType() == KGE_EVENT(KeyUpEvent)
87 || evt->GetType() == KGE_EVENT(KeyCharEvent) || evt->GetType() == KGE_EVENT(IMEInputEvent);
88 }
89};
90
93} // namespace kiwano
事件类型
Definition: EventType.h:36
事件
Definition: Event.h:43
const EventType & GetType() const
获取类型事件
Definition: Event.h:91
输入法输入事件
Definition: KeyEvent.h:74
String value
输入内容
Definition: KeyEvent.h:76
键盘字符事件
Definition: KeyEvent.h:64
char value
字符
Definition: KeyEvent.h:66
键盘按下事件
Definition: KeyEvent.h:44
KeyCode code
键值
Definition: KeyEvent.h:46
键盘事件
Definition: KeyEvent.h:36
键盘抬起事件
Definition: KeyEvent.h:54
KeyCode code
键值
Definition: KeyEvent.h:56
事件特性:判断事件类型是否相同
Definition: Event.h:81