[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / EcoreKeyEventArgs.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19
20 namespace ElmSharp
21 {
22     /// <summary>
23     /// It inherits System.EventArgs.
24     /// The EcoreKeyEventArgs is an EventArgs to record the Ecore event's key name and key code.
25     /// </summary>
26     /// <since_tizen> preview </since_tizen>
27     public class EcoreKeyEventArgs : EventArgs
28     {
29         /// <summary>
30         /// Gets the KeyName property. The return type is string.
31         /// </summary>
32         /// <since_tizen> preview </since_tizen>
33         public string KeyName { get; private set; }
34         /// <summary>
35         /// Gets the KeyCode property. The return type is int.
36         /// </summary>
37         /// <since_tizen> preview </since_tizen>
38         public int KeyCode { get; private set; }
39
40         /// <summary>
41         /// Creates and initializes a new instance of the EcoreKeyEventArgs class.
42         /// </summary>
43         /// <param name="data">data</param>
44         /// <param name="type">type</param>
45         /// <param name="info">information</param>
46         /// <returns>New instance of the EcoreKeyEventArgs class.</returns>
47         /// <since_tizen> preview </since_tizen>
48         public static EcoreKeyEventArgs Create(IntPtr data, EcoreEventType type, IntPtr info)
49         {
50             var evt = Marshal.PtrToStructure<EcoreEventKey>(info);
51             return new EcoreKeyEventArgs { KeyName = evt.keyname, KeyCode = (int)evt.keycode };
52         }
53
54         [StructLayout(LayoutKind.Sequential)]
55         struct EcoreEventKey
56         {
57             public string keyname;
58             public string key;
59             public string str;
60             public string compose;
61             public IntPtr window;
62             public IntPtr root_window;
63             public IntPtr event_window;
64             public uint timestamp;
65             public uint modifiers;
66             public int same_screen;
67             public uint keycode;
68             public IntPtr data;
69             public IntPtr dev;
70         }
71     }
72 }