/
EvasKeyEventArgs.cs
172 lines (149 loc) · 5.3 KB
/
EvasKeyEventArgs.cs
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Runtime.InteropServices;
using Tizen.Internals;
namespace ElmSharp
{
/// <summary>
/// The EvasKeyEventArgs is a EvasKey EventArgs.
/// </summary>
/// <since_tizen> preview </since_tizen>
public class EvasKeyEventArgs : EventArgs
{
IntPtr _nativeEventInfo;
/// <summary>
/// BackButton name in platform.
/// </summary>
/// <since_tizen> preview </since_tizen>
public const string PlatformBackButtonName = "XF86Back";
/// <summary>
/// MenuButton name in platform.
/// </summary>
/// <since_tizen> preview </since_tizen>
public const string PlatformMenuButtonName = "XF86Menu";
/// <summary>
/// HomeButton name in platform.
/// </summary>
/// <since_tizen> preview </since_tizen>
public const string PlatformHomeButtonName = "XF86Home";
/// <summary>
/// Gets the name of the key.
/// </summary>
/// <since_tizen> preview </since_tizen>
public string KeyName { get; private set; }
/// <summary>
/// Sets or gets the flags.
/// </summary>
/// <since_tizen> preview </since_tizen>
public EvasEventFlag Flags
{
get
{
IntPtr offset = Marshal.OffsetOf<EvasEventKeyDown>("event_flags");
return (EvasEventFlag)Marshal.ReadIntPtr(_nativeEventInfo, (int)offset);
}
set
{
IntPtr offset = Marshal.OffsetOf<EvasEventKeyDown>("event_flags");
Marshal.WriteIntPtr(_nativeEventInfo, (int)offset, (IntPtr)value);
}
}
EvasKeyEventArgs(IntPtr info)
{
_nativeEventInfo = info;
var evt = Marshal.PtrToStructure<EvasEventKeyDown>(info);
KeyName = evt.keyname;
}
/// <summary>
/// Creates and initializes a new instance of the EvasKeyEventArgs class.
/// </summary>
/// <param name="data">The data information.</param>
/// <param name="obj">The object.</param>
/// <param name="info">The information.</param>
/// <returns>EvasKey eventArgs.</returns>
/// <since_tizen> preview </since_tizen>
static public EvasKeyEventArgs Create(IntPtr data, IntPtr obj, IntPtr info)
{
return new EvasKeyEventArgs(info);
}
/// <summary>
/// Event structure for Key Down event callbacks.
/// </summary>
[NativeStruct("Evas_Event_Key_Down", Include="Elementary.h", PkgConfig="elementary")]
[StructLayout(LayoutKind.Sequential)]
struct EvasEventKeyDown
{
/// <summary>
/// Name string of the key pressed.
/// </summary>
public string keyname;
/// <summary>
/// Data to be passed to the event.
/// </summary>
public IntPtr data;
/// <summary>
/// Modifier keys pressed during the event.
/// </summary>
public IntPtr modifiers;
/// <summary>
/// Locks information.
/// </summary>
public IntPtr locks;
/// <summary>
/// Logical key: (example, shift+1 == exclamation).
/// </summary>
public string key;
/// <summary>
/// UTF-8 string, if this keystroke has produced a visible string to be added.
/// </summary>
public string str;
/// <summary>
/// UTF-8 string, if this keystroke has modified a string in the middle of being composed - this string replaces the previous one.
/// </summary>
public string compose;
public uint timestamp;
/// <summary>
/// Event_flags.
/// </summary>
public EvasEventFlag event_flags;
/// <summary>
///
/// </summary>
public IntPtr dev;
/// <summary>
/// Keycode.
/// </summary>
public uint keycode;
};
}
/// <summary>
/// Flags for the events.
/// </summary>
/// <since_tizen> preview </since_tizen>
[Flags]
public enum EvasEventFlag
{
/// <summary>
/// No fancy flags set.
/// </summary>
None = 0,
/// <summary>
/// This event is being delivered but should be put "on hold" until the on hold flag is unset. The event should be used for informational purposes and maybe some indications visually, but not actually perform anything.
/// </summary>
OnHold = 1,
}
}