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.
19 using System.ComponentModel;
25 /// The key structure is used to store a key press.
27 /// <since_tizen> 3 </since_tizen>
28 public class Key : BaseHandle
32 /// The default constructor.
34 /// <since_tizen> 3 </since_tizen>
35 public Key() : this(Interop.Key.New("", "", 0, 0, 0u, 0), true)
37 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
43 /// <param name="keyName">The name of the key pressed or command from the IMF, if later, then the following parameters will be needed.</param>
44 /// <param name="keyString">A string of input characters or key pressed.</param>
45 /// <param name="keyCode">The unique key code for the key pressed.</param>
46 /// <param name="keyModifier">The key modifier for special keys like Shift and Alt.</param>
47 /// <param name="timeStamp">The time (in ms) that the key event occurred.</param>
48 /// <param name="keyState">The state of the key event.</param>
49 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)
51 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54 internal Key(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Key.Upcast(cPtr), cMemoryOwn)
59 /// Enumeration for specifying the state of the key event.
61 /// <since_tizen> 3 </since_tizen>
67 /// <since_tizen> 3 </since_tizen>
72 /// <since_tizen> 3 </since_tizen>
77 /// <since_tizen> 3 </since_tizen>
84 /// <since_tizen> 3 </since_tizen>
85 public string DeviceName
89 string ret = Interop.NDalic.GetDeviceName(SwigCPtr);
90 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
96 /// Name given to the key pressed.
98 /// <since_tizen> 3 </since_tizen>
99 public string KeyPressedName
103 string ret = Interop.Key.KeyPressedNameGet(SwigCPtr);
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
109 Interop.Key.KeyPressedNameSet(SwigCPtr, value);
110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116 /// Get the logical key string. (eg. shift + 1 == "exclamation")
118 /// <returns>The logical key symbol</returns>
119 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
120 [EditorBrowsable(EditorBrowsableState.Never)]
121 public string LogicalKey
125 string ret = Interop.Key.LogicalKeyGet(SwigCPtr);
126 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
132 /// Get the actual string returned that should be used for input editors.
134 /// <returns>The key string</returns>
135 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
136 [EditorBrowsable(EditorBrowsableState.Never)]
137 public string KeyPressed
146 /// Get the actual string returned that should be used for input editors.
148 /// <returns>The key string</returns>
149 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
150 [EditorBrowsable(EditorBrowsableState.Never)]
151 public string KeyString
155 string ret = Interop.Key.KeyStringGet(SwigCPtr);
156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
161 Interop.Key.KeyStringSet(SwigCPtr, value);
162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167 /// Keycode for the key pressed.
169 /// <since_tizen> 3 </since_tizen>
174 int ret = Interop.Key.KeyCodeGet(SwigCPtr);
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
180 Interop.Key.KeyCodeSet(SwigCPtr, value);
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186 /// Special keys like Shift, Alt, and Ctrl which modify the next key pressed.
188 /// <since_tizen> 3 </since_tizen>
189 public int KeyModifier
193 int ret = Interop.Key.KeyModifierGet(SwigCPtr);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
199 Interop.Key.KeyModifierSet(SwigCPtr, value);
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 /// The time (in ms) that the key event occurred.
207 /// <since_tizen> 3 </since_tizen>
212 uint ret = Interop.Key.TimeGet(SwigCPtr);
213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
218 Interop.Key.TimeSet(SwigCPtr, value);
219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224 /// State of the key event.
226 /// <since_tizen> 3 </since_tizen>
227 public Key.StateType State
231 Key.StateType ret = (Key.StateType)Interop.Key.StateGet(SwigCPtr);
232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
237 Interop.Key.StateSet(SwigCPtr, (int)value);
238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 /// Get the device class the key event originated from.
245 /// <since_tizen> 3 </since_tizen>
246 public DeviceClassType DeviceClass
250 int ret = Interop.NDalic.GetDeviceClass(SwigCPtr);
251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
252 return (DeviceClassType)ret;
257 /// Get the device subclass the key event originated from.
259 /// <since_tizen> 4 </since_tizen>
260 public DeviceSubClassType DeviceSubClass
264 int ret = Interop.NDalic.GetDeviceSubClass(SwigCPtr);
265 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
266 return (DeviceSubClassType)ret;
270 private string keyPressed
274 Interop.Key.KeyPressedSet(SwigCPtr, value);
275 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279 string ret = Interop.Key.KeyPressedGet(SwigCPtr);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286 /// Checks to see if the Shift key modifier has been supplied.
288 /// <returns>True if Shift modifier.</returns>
289 /// <since_tizen> 3 </since_tizen>
290 public bool IsShiftModifier()
292 bool ret = Interop.Key.IsShiftModifier(SwigCPtr);
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
298 /// Checks to see if Ctrl (control) key modifier has been supplied.
300 /// <returns>True if Ctrl modifier.</returns>
301 /// <since_tizen> 3 </since_tizen>
302 public bool IsCtrlModifier()
304 bool ret = Interop.Key.IsCtrlModifier(SwigCPtr);
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 /// Checks to see if Alt key modifier has been supplied.
312 /// <returns>True if Alt modifier.</returns>
313 /// <since_tizen> 3 </since_tizen>
314 public bool IsAltModifier()
316 bool ret = Interop.Key.IsAltModifier(SwigCPtr);
317 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Key obj)
323 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
326 internal static Key GetKeyFromPtr(global::System.IntPtr cPtr)
328 Key ret = new Key(cPtr, false);
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 /// This will not be public opened.
334 [EditorBrowsable(EditorBrowsableState.Never)]
335 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
337 Interop.Key.DeleteKey(swigCPtr);