/*
* Copyright(c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.ComponentModel;
namespace Tizen.NUI
{
///
/// The key structure is used to store a key press.
///
/// 3
public class Key : BaseHandle
{
///
/// The default constructor.
///
/// 3
public Key() : this(Interop.Key.New("", "", 0, 0, 0u, 0), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The constructor.
///
/// The name of the key pressed or command from the IMF, if later, then the following parameters will be needed.
/// A string of input characters or key pressed.
/// The unique key code for the key pressed.
/// The key modifier for special keys like Shift and Alt.
/// The time (in ms) that the key event occurred.
/// The state of the key event.
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)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal Key(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Key.Upcast(cPtr), cMemoryOwn)
{
}
///
/// Enumeration for specifying the state of the key event.
///
/// 3
public enum StateType
{
///
/// Key Down.
///
/// 3
Down,
///
/// Key Up.
///
/// 3
Up,
///
/// Key Last.
///
/// 3
Last
}
///
/// Device name
///
/// 3
public string DeviceName
{
get
{
string ret = Interop.NDalic.GetDeviceName(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// Name given to the key pressed.
///
/// 3
public string KeyPressedName
{
get
{
string ret = Interop.Key.KeyPressedNameGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
set
{
Interop.Key.KeyPressedNameSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
///
/// Get the logical key string. (eg. shift + 1 == "exclamation")
///
/// The logical key symbol
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public string LogicalKey
{
get
{
string ret = Interop.Key.LogicalKeyGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// Get the actual string returned that should be used for input editors.
///
/// The key string
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public string KeyPressed
{
get
{
return keyPressed;
}
}
///
/// Get the actual string returned that should be used for input editors.
///
/// The key string
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public string KeyString
{
get
{
string ret = Interop.Key.KeyStringGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
set
{
Interop.Key.KeyStringSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
///
/// Keycode for the key pressed.
///
/// 3
public int KeyCode
{
get
{
int ret = Interop.Key.KeyCodeGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
set
{
Interop.Key.KeyCodeSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
///
/// Special keys like Shift, Alt, and Ctrl which modify the next key pressed.
///
/// 3
public int KeyModifier
{
get
{
int ret = Interop.Key.KeyModifierGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
set
{
Interop.Key.KeyModifierSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
///
/// The time (in ms) that the key event occurred.
///
/// 3
public uint Time
{
get
{
uint ret = Interop.Key.TimeGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
set
{
Interop.Key.TimeSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
///
/// State of the key event.
///
/// 3
public Key.StateType State
{
get
{
Key.StateType ret = (Key.StateType)Interop.Key.StateGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
set
{
Interop.Key.StateSet(swigCPtr, (int)value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
///
/// Get the device class the key event originated from.
///
/// 3
public DeviceClassType DeviceClass
{
get
{
int ret = Interop.NDalic.GetDeviceClass(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return (DeviceClassType)ret;
}
}
///
/// Get the device subclass the key event originated from.
///
/// 4
public DeviceSubClassType DeviceSubClass
{
get
{
int ret = Interop.NDalic.GetDeviceSubClass(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return (DeviceSubClassType)ret;
}
}
private string keyPressed
{
set
{
Interop.Key.KeyPressedSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
string ret = Interop.Key.KeyPressedGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// Checks to see if the Shift key modifier has been supplied.
///
/// True if Shift modifier.
/// 3
public bool IsShiftModifier()
{
bool ret = Interop.Key.IsShiftModifier(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Checks to see if Ctrl (control) key modifier has been supplied.
///
/// True if Ctrl modifier.
/// 3
public bool IsCtrlModifier()
{
bool ret = Interop.Key.IsCtrlModifier(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Checks to see if Alt key modifier has been supplied.
///
/// True if Alt modifier.
/// 3
public bool IsAltModifier()
{
bool ret = Interop.Key.IsAltModifier(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Key obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
internal static Key GetKeyFromPtr(global::System.IntPtr cPtr)
{
Key ret = new Key(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
Interop.Key.DeleteKey(swigCPtr);
}
}
}