2 * Copyright(c) 2020 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 : BaseHandle
31 /// The default constructor.
33 /// <since_tizen> 3 </since_tizen>
34 public Key() : this(Interop.Key.Key_New("", "", 0, 0, 0u, 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.Key_New(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(Interop.Key.Key_SWIGUpcast(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 string ret = Interop.Key.Key_keyPressedName_get(swigCPtr);
103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 Interop.Key.Key_keyPressedName_set(swigCPtr, value);
109 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115 /// Get the logical key string. (eg. shift + 1 == "exclamation")
117 /// <returns>The logical key symbol</returns>
118 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
119 [EditorBrowsable(EditorBrowsableState.Never)]
120 public string LogicalKey
124 string ret = Interop.Key.Key_logicalKey_get(swigCPtr);
125 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 /// Get the actual string returned that should be used for input editors.
133 /// <returns>The key string</returns>
134 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
135 [EditorBrowsable(EditorBrowsableState.Never)]
136 public string KeyPressed
145 /// Get the actual string returned that should be used for input editors.
147 /// <returns>The key string</returns>
148 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
149 [EditorBrowsable(EditorBrowsableState.Never)]
150 public string KeyString
154 string ret = Interop.Key.Key_keyString_get(swigCPtr);
155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160 Interop.Key.Key_keyString_set(swigCPtr, value);
161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166 /// Keycode for the key pressed.
168 /// <since_tizen> 3 </since_tizen>
173 int ret = Interop.Key.Key_keyCode_get(swigCPtr);
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 Interop.Key.Key_keyCode_set(swigCPtr, value);
180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185 /// Special keys like Shift, Alt, and Ctrl which modify the next key pressed.
187 /// <since_tizen> 3 </since_tizen>
188 public int KeyModifier
192 int ret = Interop.Key.Key_keyModifier_get(swigCPtr);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198 Interop.Key.Key_keyModifier_set(swigCPtr, value);
199 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204 /// The time (in ms) that the key event occurred.
206 /// <since_tizen> 3 </since_tizen>
211 uint ret = Interop.Key.Key_time_get(swigCPtr);
212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 Interop.Key.Key_time_set(swigCPtr, value);
218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 /// State of the key event.
225 /// <since_tizen> 3 </since_tizen>
226 public Key.StateType State
230 Key.StateType ret = (Key.StateType)Interop.Key.Key_state_get(swigCPtr);
231 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236 Interop.Key.Key_state_set(swigCPtr, (int)value);
237 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// Get the device class the key event originated from.
244 /// <since_tizen> 3 </since_tizen>
245 public DeviceClassType DeviceClass
249 int ret = Interop.NDalic.GetDeviceClass(swigCPtr);
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 return (DeviceClassType)ret;
256 /// Get the device subclass the key event originated from.
258 /// <since_tizen> 4 </since_tizen>
259 public DeviceSubClassType DeviceSubClass
263 int ret = Interop.NDalic.GetDeviceSubClass(swigCPtr);
264 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 return (DeviceSubClassType)ret;
269 private string keyPressed
273 Interop.Key.Key_keyPressed_set(swigCPtr, value);
274 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278 string ret = Interop.Key.Key_keyPressed_get(swigCPtr);
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 /// Checks to see if the Shift key modifier has been supplied.
287 /// <returns>True if Shift modifier.</returns>
288 /// <since_tizen> 3 </since_tizen>
289 public bool IsShiftModifier()
291 bool ret = Interop.Key.Key_IsShiftModifier(swigCPtr);
292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297 /// Checks to see if Ctrl (control) key modifier has been supplied.
299 /// <returns>True if Ctrl modifier.</returns>
300 /// <since_tizen> 3 </since_tizen>
301 public bool IsCtrlModifier()
303 bool ret = Interop.Key.Key_IsCtrlModifier(swigCPtr);
304 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309 /// Checks to see if Alt key modifier has been supplied.
311 /// <returns>True if Alt modifier.</returns>
312 /// <since_tizen> 3 </since_tizen>
313 public bool IsAltModifier()
315 bool ret = Interop.Key.Key_IsAltModifier(swigCPtr);
316 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
320 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Key obj)
322 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
325 internal static Key GetKeyFromPtr(global::System.IntPtr cPtr)
327 Key ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Key;
330 ret = new Key(cPtr, false);
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 /// This will not be public opened.
337 [EditorBrowsable(EditorBrowsableState.Never)]
338 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
340 Interop.Key.delete_Key(swigCPtr);