Release 4.0.0-preview1-00051
[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 a EventArgs to record Ecore event's key name and key code.
25     /// </summary>
26     public class EcoreKeyEventArgs : EventArgs
27     {
28         /// <summary>
29         /// Gets the KeyName property.The return type is string.
30         /// </summary>
31         public string KeyName { get; private set; }
32         /// <summary>
33         /// Gets the KeyCode property.The return type is int.
34         /// </summary>
35         public int KeyCode { get; private set; }
36
37         /// <summary>
38         /// Creates and initializes a new instance of the EcoreKeyEventArgs class.
39         /// </summary>
40         /// <param name="data">data</param>
41         /// <param name="type">type</param>
42         /// <param name="info">information </param>
43         /// <returns>new instance of the EcoreKeyEventArgs class</returns>
44         public static EcoreKeyEventArgs Create(IntPtr data, EcoreEventType type, IntPtr info)
45         {
46             var evt = Marshal.PtrToStructure<EcoreEventKey>(info);
47             return new EcoreKeyEventArgs { KeyName = evt.keyname, KeyCode = (int)evt.keycode };
48         }
49
50         [StructLayout(LayoutKind.Sequential)]
51         struct EcoreEventKey
52         {
53             public string keyname;
54             public string key;
55             public string str;
56             public string compose;
57             public IntPtr window;
58             public IntPtr root_window;
59             public IntPtr event_window;
60             public uint timestamp;
61             public uint modifiers;
62             public int same_screen;
63             public uint keycode;
64             public IntPtr data;
65             public IntPtr dev;
66         }
67     }
68 }