GetCharacterIndex() private method

private GetCharacterIndex ( Vector2 localPos ) : int
localPos Vector2
return int
Esempio n. 1
0
    static int GetCharacterIndex(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        UILabel obj  = (UILabel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UILabel");
        int     arg0 = (int)LuaScriptMgr.GetNumber(L, 2);
        KeyCode arg1 = (KeyCode)LuaScriptMgr.GetNetObject(L, 3, typeof(KeyCode));
        int     o    = obj.GetCharacterIndex(arg0, arg1);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Esempio n. 2
0
 static public int GetCharacterIndex(IntPtr l)
 {
     try {
         UILabel      self = (UILabel)checkSelf(l);
         System.Int32 a1;
         checkType(l, 2, out a1);
         UnityEngine.KeyCode a2;
         checkEnum(l, 3, out a2);
         var ret = self.GetCharacterIndex(a1, a2);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 3
0
	static int GetCharacterIndex(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 3);
			UILabel obj = (UILabel)ToLua.CheckObject<UILabel>(L, 1);
			int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
			UnityEngine.KeyCode arg1 = (UnityEngine.KeyCode)ToLua.CheckObject(L, 3, typeof(UnityEngine.KeyCode));
			int o = obj.GetCharacterIndex(arg0, arg1);
			LuaDLL.lua_pushinteger(L, o);
			return 1;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}
Esempio n. 4
0
    public static int GetCharacterIndex(IntPtr l)
    {
        int result;

        try
        {
            UILabel uILabel = (UILabel)LuaObject.checkSelf(l);
            int     currentIndex;
            LuaObject.checkType(l, 2, out currentIndex);
            KeyCode key;
            LuaObject.checkEnum <KeyCode>(l, 3, out key);
            int characterIndex = uILabel.GetCharacterIndex(currentIndex, key);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, characterIndex);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Esempio n. 5
0
    public virtual bool ProcessEvent(Event ev)
    {
        if (label == null)
        {
            return(false);
        }
        RuntimePlatform platform = Application.platform;
        bool            flag     = (platform != 0 && platform != RuntimePlatform.OSXPlayer && platform != RuntimePlatform.OSXWebPlayer) ? ((ev.modifiers & EventModifiers.Control) != 0) : ((ev.modifiers & EventModifiers.Command) != 0);

        if ((ev.modifiers & EventModifiers.Alt) != 0)
        {
            flag = false;
        }
        bool flag2 = (ev.modifiers & EventModifiers.Shift) != 0;

        switch (ev.keyCode)
        {
        case KeyCode.Backspace:
            ev.Use();
            DoBackspace();
            return(true);

        case KeyCode.Delete:
            ev.Use();
            if (!string.IsNullOrEmpty(mValue))
            {
                if (mSelectionStart == mSelectionEnd)
                {
                    if (mSelectionStart >= mValue.Length)
                    {
                        return(true);
                    }
                    mSelectionEnd++;
                }
                Insert(string.Empty);
            }
            return(true);

        case KeyCode.LeftArrow:
            ev.Use();
            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = Mathf.Max(mSelectionEnd - 1, 0);
                if (!flag2)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);

        case KeyCode.RightArrow:
            ev.Use();
            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = Mathf.Min(mSelectionEnd + 1, mValue.Length);
                if (!flag2)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);

        case KeyCode.PageUp:
            ev.Use();
            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = 0;
                if (!flag2)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);

        case KeyCode.PageDown:
            ev.Use();
            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = mValue.Length;
                if (!flag2)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);

        case KeyCode.Home:
            ev.Use();
            if (!string.IsNullOrEmpty(mValue))
            {
                if (label.multiLine)
                {
                    mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.Home);
                }
                else
                {
                    mSelectionEnd = 0;
                }
                if (!flag2)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);

        case KeyCode.End:
            ev.Use();
            if (!string.IsNullOrEmpty(mValue))
            {
                if (label.multiLine)
                {
                    mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.End);
                }
                else
                {
                    mSelectionEnd = mValue.Length;
                }
                if (!flag2)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);

        case KeyCode.UpArrow:
            ev.Use();
            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.UpArrow);
                if (mSelectionEnd != 0)
                {
                    mSelectionEnd += mDrawStart;
                }
                if (!flag2)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);

        case KeyCode.DownArrow:
            ev.Use();
            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.DownArrow);
                if (mSelectionEnd != label.processedText.Length)
                {
                    mSelectionEnd += mDrawStart;
                }
                else
                {
                    mSelectionEnd = mValue.Length;
                }
                if (!flag2)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);

        case KeyCode.A:
            if (flag)
            {
                ev.Use();
                mSelectionStart = 0;
                mSelectionEnd   = mValue.Length;
                UpdateLabel();
            }
            return(true);

        case KeyCode.C:
            if (flag)
            {
                ev.Use();
                NGUITools.clipboard = GetSelection();
            }
            return(true);

        case KeyCode.V:
            if (flag)
            {
                ev.Use();
                Insert(NGUITools.clipboard);
            }
            return(true);

        case KeyCode.X:
            if (flag)
            {
                ev.Use();
                NGUITools.clipboard = GetSelection();
                Insert(string.Empty);
            }
            return(true);

        default:
            return(false);
        }
    }
Esempio n. 6
0
    /// <summary>
    /// Handle the specified event.
    /// </summary>

    protected virtual bool ProcessEvent(Event ev)
    {
        if (label == null)
        {
            return(false);
        }

        RuntimePlatform rp = Application.platform;

        bool isMac = (
            rp == RuntimePlatform.OSXEditor ||
            rp == RuntimePlatform.OSXPlayer ||
            rp == RuntimePlatform.OSXWebPlayer);

        bool ctrl = isMac ?
                    ((ev.modifiers & EventModifiers.Command) != 0) :
                    ((ev.modifiers & EventModifiers.Control) != 0);

        // http://www.tasharen.com/forum/index.php?topic=10780.0
        if ((ev.modifiers & EventModifiers.Alt) != 0)
        {
            ctrl = false;
        }

        bool shift = ((ev.modifiers & EventModifiers.Shift) != 0);

        switch (ev.keyCode)
        {
        case KeyCode.Backspace:
        {
            ev.Use();
            DoBackspace();
            return(true);
        }

        case KeyCode.Delete:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                if (mSelectionStart == mSelectionEnd)
                {
                    if (mSelectionStart >= mValue.Length)
                    {
                        return(true);
                    }
                    ++mSelectionEnd;
                }
                Insert("");
            }
            return(true);
        }

        case KeyCode.LeftArrow:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = Mathf.Max(mSelectionEnd - 1, 0);
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.RightArrow:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = Mathf.Min(mSelectionEnd + 1, mValue.Length);
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.PageUp:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = 0;
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.PageDown:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = mValue.Length;
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.Home:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                if (label.multiLine)
                {
                    mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.Home);
                }
                else
                {
                    mSelectionEnd = 0;
                }

                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.End:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                if (label.multiLine)
                {
                    mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.End);
                }
                else
                {
                    mSelectionEnd = mValue.Length;
                }

                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.UpArrow:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.UpArrow);
                if (mSelectionEnd != 0)
                {
                    mSelectionEnd += mDrawStart;
                }
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.DownArrow:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.DownArrow);
                if (mSelectionEnd != label.processedText.Length)
                {
                    mSelectionEnd += mDrawStart;
                }
                else
                {
                    mSelectionEnd = mValue.Length;
                }
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        // Select all
        case KeyCode.A:
        {
            if (ctrl)
            {
                ev.Use();
                mSelectionStart = 0;
                mSelectionEnd   = mValue.Length;
                UpdateLabel();
            }
            return(true);
        }

        // Copy
        case KeyCode.C:
        {
            if (ctrl)
            {
                ev.Use();
                NGUITools.clipboard = GetSelection();
            }
            return(true);
        }

        // Paste
        case KeyCode.V:
        {
            if (ctrl)
            {
                ev.Use();
                Insert(NGUITools.clipboard);
            }
            return(true);
        }

        // Cut
        case KeyCode.X:
        {
            if (ctrl)
            {
                ev.Use();
                NGUITools.clipboard = GetSelection();
                Insert("");
            }
            return(true);
        }

        // Submit
        case KeyCode.Return:
        case KeyCode.KeypadEnter:
        {
            ev.Use();

            bool newLine = (onReturnKey == OnReturnKey.NewLine) ||
                           (onReturnKey == OnReturnKey.Default &&
                            label.multiLine && !ctrl &&
                            label.overflowMethod != UILabel.Overflow.ClampContent &&
                            validation == Validation.None);

            if (newLine)
            {
                Insert("\n");
            }
            else
            {
                UICamera.currentScheme = UICamera.ControlScheme.Controller;
                UICamera.currentKey    = ev.keyCode;
                Submit();
                UICamera.currentKey = KeyCode.None;
            }
            return(true);
        }
        }
        return(false);
    }
Esempio n. 7
0
    /// <summary>
    /// Handle the specified event.
    /// </summary>

    public virtual bool ProcessEvent(Event ev)
    {
        if (label == null)
        {
            return(false);
        }

        RuntimePlatform rp = Application.platform;

        bool isMac = (
            rp == RuntimePlatform.OSXEditor ||
            rp == RuntimePlatform.OSXPlayer
            );

        bool ctrl = isMac ?
                    ((ev.modifiers & EventModifiers.Command) != 0) :
                    ((ev.modifiers & EventModifiers.Control) != 0);

        // http://www.tasharen.com/forum/index.php?topic=10780.0
        if ((ev.modifiers & EventModifiers.Alt) != 0)
        {
            ctrl = false;
        }

        bool shift = ((ev.modifiers & EventModifiers.Shift) != 0);

        switch (ev.keyCode)
        {
        case KeyCode.Backspace:
        {
            ev.Use();
            DoBackspace();
            return(true);
        }

        case KeyCode.Delete:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                if (mSelectionStart == mSelectionEnd)
                {
                    if (mSelectionStart >= mValue.Length)
                    {
                        return(true);
                    }
                    ++mSelectionEnd;
                }
                Insert("");
            }
            return(true);
        }

        case KeyCode.LeftArrow:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = Mathf.Max(mSelectionEnd - 1, 0);
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.RightArrow:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = Mathf.Min(mSelectionEnd + 1, mValue.Length);
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.PageUp:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = 0;
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.PageDown:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = mValue.Length;
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.Home:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                if (label.multiLine)
                {
                    mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.Home);
                }
                else
                {
                    mSelectionEnd = 0;
                }

                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.End:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                if (label.multiLine)
                {
                    mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.End);
                }
                else
                {
                    mSelectionEnd = mValue.Length;
                }

                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.UpArrow:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.UpArrow);
                if (mSelectionEnd != 0)
                {
                    mSelectionEnd += mDrawStart;
                }
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        case KeyCode.DownArrow:
        {
            ev.Use();

            if (!string.IsNullOrEmpty(mValue))
            {
                mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.DownArrow);
                if (mSelectionEnd != label.processedText.Length)
                {
                    mSelectionEnd += mDrawStart;
                }
                else
                {
                    mSelectionEnd = mValue.Length;
                }
                if (!shift)
                {
                    mSelectionStart = mSelectionEnd;
                }
                UpdateLabel();
            }
            return(true);
        }

        // Select all
        case KeyCode.A:
        {
            if (ctrl)
            {
                ev.Use();
                mSelectionStart = 0;
                mSelectionEnd   = mValue.Length;
                UpdateLabel();
            }
            return(true);
        }

        // Copy
        case KeyCode.C:
        {
            if (ctrl)
            {
                ev.Use();
                NGUITools.clipboard = GetSelection();
            }
            return(true);
        }

        // Paste
        case KeyCode.V:
        {
            if (ctrl)
            {
                ev.Use();
                Insert(NGUITools.clipboard);
            }
            return(true);
        }

        // Cut
        case KeyCode.X:
        {
            if (ctrl)
            {
                ev.Use();
                NGUITools.clipboard = GetSelection();
                Insert("");
            }
            return(true);
        }
        }
        return(false);
    }
Esempio n. 8
0
    public virtual bool ProcessEvent(Event ev)
    {
        if (!(label == null))
        {
            RuntimePlatform platform = Application.platform;
            bool            flag     = (platform != 0 && platform != RuntimePlatform.OSXPlayer && platform != RuntimePlatform.OSXWebPlayer) ? ((ev.modifiers & EventModifiers.Control) != EventModifiers.None) : ((ev.modifiers & EventModifiers.Command) != EventModifiers.None);
            if ((ev.modifiers & EventModifiers.Alt) != 0)
            {
                flag = false;
            }
            bool flag2 = (ev.modifiers & EventModifiers.Shift) != EventModifiers.None;
            switch (ev.keyCode)
            {
            case KeyCode.Backspace:
                ev.Use();
                DoBackspace();
                return(true);

            case KeyCode.Delete:
                ev.Use();
                if (!string.IsNullOrEmpty(mValue))
                {
                    if (mSelectionStart == mSelectionEnd)
                    {
                        if (mSelectionStart >= mValue.Length)
                        {
                            return(true);
                        }
                        mSelectionEnd++;
                    }
                    Insert(string.Empty);
                }
                return(true);

            case KeyCode.LeftArrow:
                ev.Use();
                if (!string.IsNullOrEmpty(mValue))
                {
                    mSelectionEnd = Mathf.Max(mSelectionEnd - 1, 0);
                    if (!flag2)
                    {
                        mSelectionStart = mSelectionEnd;
                    }
                    UpdateLabel();
                }
                return(true);

            case KeyCode.RightArrow:
                ev.Use();
                if (!string.IsNullOrEmpty(mValue))
                {
                    mSelectionEnd = Mathf.Min(mSelectionEnd + 1, mValue.Length);
                    if (!flag2)
                    {
                        mSelectionStart = mSelectionEnd;
                    }
                    UpdateLabel();
                }
                return(true);

            case KeyCode.PageUp:
                ev.Use();
                if (!string.IsNullOrEmpty(mValue))
                {
                    mSelectionEnd = 0;
                    if (!flag2)
                    {
                        mSelectionStart = mSelectionEnd;
                    }
                    UpdateLabel();
                }
                return(true);

            case KeyCode.PageDown:
                ev.Use();
                if (!string.IsNullOrEmpty(mValue))
                {
                    mSelectionEnd = mValue.Length;
                    if (!flag2)
                    {
                        mSelectionStart = mSelectionEnd;
                    }
                    UpdateLabel();
                }
                return(true);

            case KeyCode.Home:
                ev.Use();
                if (!string.IsNullOrEmpty(mValue))
                {
                    if (label.multiLine)
                    {
                        mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.Home);
                    }
                    else
                    {
                        mSelectionEnd = 0;
                    }
                    if (!flag2)
                    {
                        mSelectionStart = mSelectionEnd;
                    }
                    UpdateLabel();
                }
                return(true);

            case KeyCode.End:
                ev.Use();
                if (!string.IsNullOrEmpty(mValue))
                {
                    if (label.multiLine)
                    {
                        mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.End);
                    }
                    else
                    {
                        mSelectionEnd = mValue.Length;
                    }
                    if (!flag2)
                    {
                        mSelectionStart = mSelectionEnd;
                    }
                    UpdateLabel();
                }
                return(true);

            case KeyCode.UpArrow:
                ev.Use();
                if (!string.IsNullOrEmpty(mValue))
                {
                    mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.UpArrow);
                    if (mSelectionEnd != 0)
                    {
                        mSelectionEnd += mDrawStart;
                    }
                    if (!flag2)
                    {
                        mSelectionStart = mSelectionEnd;
                    }
                    UpdateLabel();
                }
                return(true);

            case KeyCode.DownArrow:
                ev.Use();
                if (!string.IsNullOrEmpty(mValue))
                {
                    mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.DownArrow);
                    if (mSelectionEnd != label.processedText.Length)
                    {
                        mSelectionEnd += mDrawStart;
                    }
                    else
                    {
                        mSelectionEnd = mValue.Length;
                    }
                    if (!flag2)
                    {
                        mSelectionStart = mSelectionEnd;
                    }
                    UpdateLabel();
                }
                return(true);

            case KeyCode.A:
                if (flag)
                {
                    ev.Use();
                    mSelectionStart = 0;
                    mSelectionEnd   = mValue.Length;
                    UpdateLabel();
                }
                return(true);

            case KeyCode.C:
                if (flag)
                {
                    ev.Use();
                    NGUITools.clipboard = GetSelection();
                }
                return(true);

            case KeyCode.V:
                if (flag)
                {
                    ev.Use();
                    Insert(NGUITools.clipboard);
                }
                return(true);

            case KeyCode.X:
                if (flag)
                {
                    ev.Use();
                    NGUITools.clipboard = GetSelection();
                    Insert(string.Empty);
                }
                return(true);

            case KeyCode.Return:
            case KeyCode.KeypadEnter:
                ev.Use();
                if (onReturnKey == OnReturnKey.NewLine || (onReturnKey == OnReturnKey.Default && label.multiLine && !flag && label.overflowMethod != UILabel.Overflow.ClampContent && validation == Validation.None))
                {
                    Insert("\n");
                }
                else
                {
                    UICamera.currentScheme = UICamera.ControlScheme.Controller;
                    UICamera.currentKey    = ev.keyCode;
                    Submit();
                    UICamera.currentKey = KeyCode.None;
                }
                return(true);

            default:
                return(false);
            }
        }
        return(false);
    }
Esempio n. 9
0
	/// <summary>
	/// Handle the specified event.
	/// </summary>

	bool ProcessEvent (Event ev)
	{
		if (label == null) return false;

		RuntimePlatform rp = Application.platform;

		bool isMac = (
			rp == RuntimePlatform.OSXEditor ||
			rp == RuntimePlatform.OSXPlayer ||
			rp == RuntimePlatform.OSXWebPlayer);

		bool ctrl = isMac ?
			((ev.modifiers & EventModifiers.Command) != 0) :
			((ev.modifiers & EventModifiers.Control) != 0);

		bool shift = ((ev.modifiers & EventModifiers.Shift) != 0);

		switch (ev.keyCode)
		{
			case KeyCode.Backspace:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					if (mSelectionStart == mSelectionEnd)
					{
						if (mSelectionStart < 1) return true;
						--mSelectionEnd;
					}
					Insert("");
				}
				return true;
			}

			case KeyCode.Delete:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					if (mSelectionStart == mSelectionEnd)
					{
						if (mSelectionStart >= mValue.Length) return true;
						++mSelectionEnd;
					}
					Insert("");
				}
				return true;
			}

			case KeyCode.LeftArrow:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					mSelectionEnd = Mathf.Max(mSelectionEnd - 1, 0);
					if (!shift) mSelectionStart = mSelectionEnd;
					UpdateLabel();
				}
				return true;
			}

			case KeyCode.RightArrow:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					mSelectionEnd = Mathf.Min(mSelectionEnd + 1, mValue.Length);
					if (!shift) mSelectionStart = mSelectionEnd;
					UpdateLabel();
				}
				return true;
			}

			case KeyCode.PageUp:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					mSelectionEnd = 0;
					if (!shift) mSelectionStart = mSelectionEnd;
					UpdateLabel();
				}
				return true;
			}

			case KeyCode.PageDown:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					mSelectionEnd = mValue.Length;
					if (!shift) mSelectionStart = mSelectionEnd;
					UpdateLabel();
				}
				return true;
			}

			case KeyCode.Home:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					if (label.multiLine)
					{
						mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.Home);
					}
					else mSelectionEnd = 0;

					if (!shift) mSelectionStart = mSelectionEnd;
					UpdateLabel();
				}
				return true;
			}

			case KeyCode.End:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					if (label.multiLine)
					{
						mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.End);
					}
					else mSelectionEnd = mValue.Length;

					if (!shift) mSelectionStart = mSelectionEnd;
					UpdateLabel();
				}
				return true;
			}

			case KeyCode.UpArrow:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.UpArrow);
					if (mSelectionEnd != 0) mSelectionEnd += mDrawStart;
					if (!shift) mSelectionStart = mSelectionEnd;
					UpdateLabel();
				}
				return true;
			}

			case KeyCode.DownArrow:
			{
				ev.Use();

				if (!string.IsNullOrEmpty(mValue))
				{
					mSelectionEnd = label.GetCharacterIndex(mSelectionEnd, KeyCode.DownArrow);
					if (mSelectionEnd != label.processedText.Length) mSelectionEnd += mDrawStart;
					else mSelectionEnd = mValue.Length;
					if (!shift) mSelectionStart = mSelectionEnd;
					UpdateLabel();
				}
				return true;
			}

			// Copy
			case KeyCode.C:
			{
				if (ctrl)
				{
					ev.Use();
					NGUITools.clipboard = GetSelection();
				}
				return true;
			}

			// Paste
			case KeyCode.V:
			{
				if (ctrl)
				{
					ev.Use();
					Insert(NGUITools.clipboard);
				}
				return true;
			}

			// Cut
			case KeyCode.X:
			{
				if (ctrl)
				{
					ev.Use();
					NGUITools.clipboard = GetSelection();
					Insert("");
				}
				return true;
			}

			// Submit
			case KeyCode.Return:
			case KeyCode.KeypadEnter:
			{
				ev.Use();
				
				if (label.multiLine && !ctrl && label.overflowMethod != UILabel.Overflow.ClampContent && validation == Validation.None)
				{
					Insert("\n");
				}
				else
				{
					UICamera.currentScheme = UICamera.ControlScheme.Controller;
					UICamera.currentKey = ev.keyCode;
					Submit();
					UICamera.currentKey = KeyCode.None;
				}
				return true;
			}
		}
		return false;
	}