2 * Copyright(c) 2019 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
31 /// The default constructor.
33 /// <since_tizen> 3 </since_tizen>
34 public Key() : this(Interop.Key.new_Key__SWIG_0(), true)
36 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
42 /// <param name="keyName">The name of the key pressed or command from the IMF, if later, then the following parameters will be needed.</param>
43 /// <param name="keyString">A string of input characters or key pressed.</param>
44 /// <param name="keyCode">The unique key code for the key pressed.</param>
45 /// <param name="keyModifier">The key modifier for special keys like Shift and Alt.</param>
46 /// <param name="timeStamp">The time (in ms) that the key event occurred.</param>
47 /// <param name="keyState">The state of the key event.</param>
48 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)
50 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
53 internal Key(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
58 /// Enumeration for specifying the state of the key event.
60 /// <since_tizen> 3 </since_tizen>
66 /// <since_tizen> 3 </since_tizen>
71 /// <since_tizen> 3 </since_tizen>
76 /// <since_tizen> 3 </since_tizen>
83 /// <since_tizen> 3 </since_tizen>
84 public string DeviceName
88 string ret = Interop.NDalic.GetDeviceName(swigCPtr);
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95 /// Name given to the key pressed.
97 /// <since_tizen> 3 </since_tizen>
98 public string KeyPressedName
102 return keyPressedName;
106 keyPressedName = value;
111 /// Get the logical key string. (eg. shift + 1 == "exclamation")
113 /// <returns>The logical key symbol</returns>
114 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
115 [EditorBrowsable(EditorBrowsableState.Never)]
116 public string LogicalKey
125 /// Get the actual string returned that should be used for input editors.
127 /// <returns>The key string</returns>
128 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
129 [EditorBrowsable(EditorBrowsableState.Never)]
130 public string KeyPressed
139 /// Get the actual string returned that should be used for input editors.
141 /// <returns>The key string</returns>
142 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
143 [EditorBrowsable(EditorBrowsableState.Never)]
144 public string KeyString
157 /// Keycode for the key pressed.
159 /// <since_tizen> 3 </since_tizen>
173 /// Special keys like Shift, Alt, and Ctrl which modify the next key pressed.
175 /// <since_tizen> 3 </since_tizen>
176 public int KeyModifier
189 /// The time (in ms) that the key event occurred.
191 /// <since_tizen> 3 </since_tizen>
205 /// State of the key event.
207 /// <since_tizen> 3 </since_tizen>
208 public Key.StateType State
221 /// Get the device class the key event originated from.
223 /// <since_tizen> 3 </since_tizen>
224 public DeviceClassType DeviceClass
228 int ret = Interop.NDalic.GetDeviceClass(swigCPtr);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230 return (DeviceClassType)ret;
235 /// Get the device subclass the key event originated from.
237 /// <since_tizen> 4 </since_tizen>
238 public DeviceSubClassType DeviceSubClass
242 int ret = Interop.NDalic.GetDeviceSubClass(swigCPtr);
243 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 return (DeviceSubClassType)ret;
248 private string keyPressedName
252 Interop.Key.Key_keyPressedName_set(swigCPtr, value);
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 string ret = Interop.Key.Key_keyPressedName_get(swigCPtr);
258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 private string keyPressed
267 Interop.Key.Key_keyPressed_set(swigCPtr, value);
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
272 string ret = Interop.Key.Key_keyPressed_get(swigCPtr);
273 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278 private string keyString
282 Interop.Key.Key_keyString_set(swigCPtr, value);
283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287 string ret = Interop.Key.Key_keyString_get(swigCPtr);
288 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297 Interop.Key.Key_keyCode_set(swigCPtr, value);
298 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 int ret = Interop.Key.Key_keyCode_get(swigCPtr);
303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
308 private int keyModifier
312 Interop.Key.Key_keyModifier_set(swigCPtr, value);
313 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 int ret = Interop.Key.Key_keyModifier_get(swigCPtr);
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
327 Interop.Key.Key_time_set(swigCPtr, value);
328 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
332 uint ret = Interop.Key.Key_time_get(swigCPtr);
333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
338 private Key.StateType state
342 Interop.Key.Key_state_set(swigCPtr, (int)value);
343 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 Key.StateType ret = (Key.StateType)Interop.Key.Key_state_get(swigCPtr);
348 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
353 private string logicalKey
357 string ret = Interop.Key.Key_logicalKey_get(swigCPtr);
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364 /// Checks to see if the Shift key modifier has been supplied.
366 /// <returns>True if Shift modifier.</returns>
367 /// <since_tizen> 3 </since_tizen>
368 public bool IsShiftModifier()
370 bool ret = Interop.Key.Key_IsShiftModifier(swigCPtr);
371 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376 /// Checks to see if Ctrl (control) key modifier has been supplied.
378 /// <returns>True if Ctrl modifier.</returns>
379 /// <since_tizen> 3 </since_tizen>
380 public bool IsCtrlModifier()
382 bool ret = Interop.Key.Key_IsCtrlModifier(swigCPtr);
383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388 /// Checks to see if Alt key modifier has been supplied.
390 /// <returns>True if Alt modifier.</returns>
391 /// <since_tizen> 3 </since_tizen>
392 public bool IsAltModifier()
394 bool ret = Interop.Key.Key_IsAltModifier(swigCPtr);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Key obj)
401 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
404 internal static Key GetKeyFromPtr(global::System.IntPtr cPtr)
406 Key ret = new Key(cPtr, false);
407 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
411 /// This will not be public opened.
412 [EditorBrowsable(EditorBrowsableState.Never)]
413 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
415 Interop.Key.delete_Key(swigCPtr);