2 * Copyright(c) 2021 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.
19 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
30 /// The default constructor.
32 /// <since_tizen> 3 </since_tizen>
33 public Key() : this(Interop.Key.New("", "", 0, 0, 0u, 0), true)
35 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
41 /// <param name="keyName">The name of the key pressed or command from the IMF, if later, then the following parameters will be needed.</param>
42 /// <param name="keyString">A string of input characters or key pressed.</param>
43 /// <param name="keyCode">The unique key code for the key pressed.</param>
44 /// <param name="keyModifier">The key modifier for special keys like Shift and Alt.</param>
45 /// <param name="timeStamp">The time (in ms) that the key event occurred.</param>
46 /// <param name="keyState">The state of the key event.</param>
47 internal Key(string keyName, string keyString, int keyCode, int keyModifier, uint timeStamp, Key.StateType keyState) : this(Interop.Key.New(keyName, keyString, keyCode, keyModifier, timeStamp, (int)keyState), true)
49 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
52 internal Key(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
57 /// Enumeration for specifying the state of the key event.
59 /// <since_tizen> 3 </since_tizen>
65 /// <since_tizen> 3 </since_tizen>
70 /// <since_tizen> 3 </since_tizen>
75 /// <since_tizen> 3 </since_tizen>
82 /// <since_tizen> 3 </since_tizen>
83 public string DeviceName
87 string ret = Interop.NDalic.GetDeviceName(SwigCPtr);
88 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
94 /// Name given to the key pressed.
96 /// <since_tizen> 3 </since_tizen>
97 public string KeyPressedName
101 string ret = Interop.Key.KeyPressedNameGet(SwigCPtr);
102 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
107 Interop.Key.KeyPressedNameSet(SwigCPtr, value);
108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114 /// Get the logical key string. (eg. shift + 1 == "exclamation")
116 /// <returns>The logical key symbol</returns>
117 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
118 [EditorBrowsable(EditorBrowsableState.Never)]
119 public string LogicalKey
123 string ret = Interop.Key.LogicalKeyGet(SwigCPtr);
124 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
130 /// Get the actual string returned that should be used for input editors.
132 /// <returns>The key string</returns>
133 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
134 [EditorBrowsable(EditorBrowsableState.Never)]
135 public string KeyPressed
144 /// Get the actual string returned that should be used for input editors.
146 /// <returns>The key string</returns>
147 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
148 [EditorBrowsable(EditorBrowsableState.Never)]
149 public string KeyString
153 string ret = Interop.Key.KeyStringGet(SwigCPtr);
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
159 Interop.Key.KeyStringSet(SwigCPtr, value);
160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165 /// Keycode for the key pressed.
167 /// <since_tizen> 3 </since_tizen>
172 int ret = Interop.Key.KeyCodeGet(SwigCPtr);
173 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
178 Interop.Key.KeyCodeSet(SwigCPtr, value);
179 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 /// Special keys like Shift, Alt, and Ctrl which modify the next key pressed.
186 /// <since_tizen> 3 </since_tizen>
187 public int KeyModifier
191 int ret = Interop.Key.KeyModifierGet(SwigCPtr);
192 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
197 Interop.Key.KeyModifierSet(SwigCPtr, value);
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 /// The time (in ms) that the key event occurred.
205 /// <since_tizen> 3 </since_tizen>
210 uint ret = Interop.Key.TimeGet(SwigCPtr);
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
216 Interop.Key.TimeSet(SwigCPtr, value);
217 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222 /// State of the key event.
224 /// <since_tizen> 3 </since_tizen>
225 public Key.StateType State
229 Key.StateType ret = (Key.StateType)Interop.Key.StateGet(SwigCPtr);
230 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
235 Interop.Key.StateSet(SwigCPtr, (int)value);
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241 /// Get the device class the key event originated from.
243 /// <since_tizen> 3 </since_tizen>
244 public DeviceClassType DeviceClass
248 int ret = Interop.NDalic.GetDeviceClass(SwigCPtr);
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
250 return (DeviceClassType)ret;
255 /// Get the device subclass the key event originated from.
257 /// <since_tizen> 4 </since_tizen>
258 public DeviceSubClassType DeviceSubClass
262 int ret = Interop.NDalic.GetDeviceSubClass(SwigCPtr);
263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
264 return (DeviceSubClassType)ret;
268 private string keyPressed
272 Interop.Key.KeyPressedSet(SwigCPtr, value);
273 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 string ret = Interop.Key.KeyPressedGet(SwigCPtr);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 /// Checks to see if the Shift key modifier has been supplied.
286 /// <returns>True if Shift modifier.</returns>
287 /// <since_tizen> 3 </since_tizen>
288 public bool IsShiftModifier()
290 bool ret = Interop.Key.IsShiftModifier(SwigCPtr);
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 /// Checks to see if Ctrl (control) key modifier has been supplied.
298 /// <returns>True if Ctrl modifier.</returns>
299 /// <since_tizen> 3 </since_tizen>
300 public bool IsCtrlModifier()
302 bool ret = Interop.Key.IsCtrlModifier(SwigCPtr);
303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
308 /// Checks to see if Alt key modifier has been supplied.
310 /// <returns>True if Alt modifier.</returns>
311 /// <since_tizen> 3 </since_tizen>
312 public bool IsAltModifier()
314 bool ret = Interop.Key.IsAltModifier(SwigCPtr);
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319 internal static Key GetKeyFromPtr(global::System.IntPtr cPtr)
321 Key ret = new Key(cPtr, false);
322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326 /// This will not be public opened.
327 [EditorBrowsable(EditorBrowsableState.Never)]
328 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
330 Interop.Key.DeleteKey(swigCPtr);