2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.ComponentModel;
24 /// The key structure is used to store a key press.
26 /// <since_tizen> 3 </since_tizen>
27 public class Key : Disposable
32 /// <since_tizen> 3 </since_tizen>
33 protected bool swigCMemOwn;
35 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
38 /// The default constructor.
40 /// <since_tizen> 3 </since_tizen>
41 public Key() : this(Interop.Key.new_Key__SWIG_0(), true)
43 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
49 /// <param name="keyName">The name of the key pressed or command from the IMF, if later, then the following parameters will be needed.</param>
50 /// <param name="keyString">A string of input characters or key pressed.</param>
51 /// <param name="keyCode">The unique key code for the key pressed.</param>
52 /// <param name="keyModifier">The key modifier for special keys like Shift and Alt.</param>
53 /// <param name="timeStamp">The time (in ms) that the key event occurred.</param>
54 /// <param name="keyState">The state of the key event.</param>
55 internal Key(string keyName, string keyString, int keyCode, int keyModifier, uint timeStamp, Key.StateType keyState) : this(Interop.Key.new_Key__SWIG_1(keyName, keyString, keyCode, keyModifier, timeStamp, (int)keyState), true)
57 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
60 internal Key(global::System.IntPtr cPtr, bool cMemoryOwn)
62 swigCMemOwn = cMemoryOwn;
63 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
67 /// Enumeration for specifying the state of the key event.
69 /// <since_tizen> 3 </since_tizen>
75 /// <since_tizen> 3 </since_tizen>
80 /// <since_tizen> 3 </since_tizen>
85 /// <since_tizen> 3 </since_tizen>
92 /// <since_tizen> 3 </since_tizen>
93 public string DeviceName
97 string ret = Interop.NDalic.GetDeviceName(swigCPtr);
98 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104 /// Name given to the key pressed.
106 /// <since_tizen> 3 </since_tizen>
107 public string KeyPressedName
111 return keyPressedName;
115 keyPressedName = value;
120 /// Get the logical key string. (eg. shift + 1 == "exclamation")
122 /// <returns>The logical key symbol</returns>
123 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
124 [EditorBrowsable(EditorBrowsableState.Never)]
125 public string LogicalKey
134 /// Get the actual string returned that should be used for input editors.
136 /// <returns>The key string</returns>
137 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
138 [EditorBrowsable(EditorBrowsableState.Never)]
139 public string KeyPressed
148 /// Get the actual string returned that should be used for input editors.
150 /// <returns>The key string</returns>
151 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
152 [EditorBrowsable(EditorBrowsableState.Never)]
153 public string KeyString
166 /// Keycode for the key pressed.
168 /// <since_tizen> 3 </since_tizen>
182 /// Special keys like Shift, Alt, and Ctrl which modify the next key pressed.
184 /// <since_tizen> 3 </since_tizen>
185 public int KeyModifier
198 /// The time (in ms) that the key event occurred.
200 /// <since_tizen> 3 </since_tizen>
214 /// State of the key event.
216 /// <since_tizen> 3 </since_tizen>
217 public Key.StateType State
230 /// Get the device class the key event originated from.
232 /// <since_tizen> 3 </since_tizen>
233 public DeviceClassType DeviceClass
237 int ret = Interop.NDalic.GetDeviceClass(swigCPtr);
238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239 return (DeviceClassType)ret;
244 /// Get the device subclass the key event originated from.
246 /// <since_tizen> 4 </since_tizen>
247 public DeviceSubClassType DeviceSubClass
251 int ret = Interop.NDalic.GetDeviceSubClass(swigCPtr);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253 return (DeviceSubClassType)ret;
257 private string keyPressedName
261 Interop.Key.Key_keyPressedName_set(swigCPtr, value);
262 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
266 string ret = Interop.Key.Key_keyPressedName_get(swigCPtr);
267 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
272 private string keyPressed
276 Interop.Key.Key_keyPressed_set(swigCPtr, value);
277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281 string ret = Interop.Key.Key_keyPressed_get(swigCPtr);
282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287 private string keyString
291 Interop.Key.Key_keyString_set(swigCPtr, value);
292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 string ret = Interop.Key.Key_keyString_get(swigCPtr);
297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
306 Interop.Key.Key_keyCode_set(swigCPtr, value);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 int ret = Interop.Key.Key_keyCode_get(swigCPtr);
312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 private int keyModifier
321 Interop.Key.Key_keyModifier_set(swigCPtr, value);
322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326 int ret = Interop.Key.Key_keyModifier_get(swigCPtr);
327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 Interop.Key.Key_time_set(swigCPtr, value);
337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 uint ret = Interop.Key.Key_time_get(swigCPtr);
342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 private Key.StateType state
351 Interop.Key.Key_state_set(swigCPtr, (int)value);
352 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
356 Key.StateType ret = (Key.StateType)Interop.Key.Key_state_get(swigCPtr);
357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362 private string logicalKey
366 string ret = Interop.Key.Key_logicalKey_get(swigCPtr);
367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
373 /// Checks to see if the Shift key modifier has been supplied.
375 /// <returns>True if Shift modifier.</returns>
376 /// <since_tizen> 3 </since_tizen>
377 public bool IsShiftModifier()
379 bool ret = Interop.Key.Key_IsShiftModifier(swigCPtr);
380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385 /// Checks to see if Ctrl (control) key modifier has been supplied.
387 /// <returns>True if Ctrl modifier.</returns>
388 /// <since_tizen> 3 </since_tizen>
389 public bool IsCtrlModifier()
391 bool ret = Interop.Key.Key_IsCtrlModifier(swigCPtr);
392 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397 /// Checks to see if Alt key modifier has been supplied.
399 /// <returns>True if Alt modifier.</returns>
400 /// <since_tizen> 3 </since_tizen>
401 public bool IsAltModifier()
403 bool ret = Interop.Key.Key_IsAltModifier(swigCPtr);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
408 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Key obj)
410 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
413 internal static Key GetKeyFromPtr(global::System.IntPtr cPtr)
415 Key ret = new Key(cPtr, false);
416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
423 /// <param name="type">The dispose type.</param>
424 /// <since_tizen> 3 </since_tizen>
425 protected override void Dispose(DisposeTypes type)
432 //Release your own unmanaged resources here.
433 //You should not access any managed member here except static instance.
434 //because the execution order of Finalizes is non-deterministic.
436 if (swigCPtr.Handle != global::System.IntPtr.Zero)
441 Interop.Key.delete_Key(swigCPtr);
443 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);