Пример #1
0
        public override bool Perform(bool repeat = false)
        {
            TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField();
            if (!!inputField)
            {
                int startPosition = inputField.selectionStringAnchorPosition;
                int endPosition   = inputField.selectionStringFocusPosition;
                if (startPosition > endPosition)
                {
                    int tmpPosition = startPosition;
                    startPosition = endPosition;
                    endPosition   = tmpPosition;
                }
                else if (startPosition == endPosition)
                {
                    if (startPosition == 0) // nothing to remove
                    {
                        return(true);
                    }

                    startPosition--;
                }

                inputField.text = inputField.text.Remove(startPosition, endPosition - startPosition);
                inputField.selectionStringFocusPosition = inputField.selectionStringAnchorPosition = startPosition;
                return(true);
            }

            return(false);
        }
Пример #2
0
        public override bool Perform(bool repeat = false)
        {
            TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField();
            if (!!inputField)
            {
                string copied = GUIUtility.systemCopyBuffer;
                if (copied == null)
                {
                    return(true);
                }

                int startPosition = inputField.selectionStringAnchorPosition;
                int endPosition   = inputField.selectionStringFocusPosition;
                if (startPosition > endPosition)
                {
                    int tmpPosition = startPosition;
                    startPosition = endPosition;
                    endPosition   = tmpPosition;
                }

                if (startPosition == endPosition)
                {
                    inputField.text = inputField.text.Insert(startPosition, copied);
                }
                else
                {
                    inputField.text = inputField.text.Remove(startPosition, endPosition - startPosition).Insert(startPosition, copied);
                }

                inputField.selectionStringFocusPosition = inputField.selectionStringAnchorPosition = startPosition + copied.Length;
                return(true);
            }

            return(false);
        }
Пример #3
0
        public override bool Perform(bool repeat = false)
        {
            TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField();
            if (!!inputField)
            {
                int startPosition = inputField.selectionStringAnchorPosition;
                int endPosition   = inputField.selectionStringFocusPosition;
                if (startPosition > endPosition)
                {
                    int tmpPosition = startPosition;
                    startPosition = endPosition;
                    endPosition   = tmpPosition;
                }
                else if (startPosition == endPosition)
                {
                    if (endPosition == inputField.text.Length)
                    {
                        return(true);
                    }

                    endPosition++;
                }

                GUIUtility.systemCopyBuffer = inputField.text.Substring(startPosition, endPosition - startPosition);
                return(true);
            }

            return(false);
        }
Пример #4
0
        public override bool KeyCallback(uint eventMask, char _, KeyCode __, EventModifiers eventModifiers)
        {
            TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField();
            if (!!inputField)
            {
                inputField.MoveTextEnd((eventModifiers & EventModifiers.Shift) != 0);
                return(true);
            }

            return(false);
        }
Пример #5
0
        public override bool Perform(bool repeat = false)
        {
            TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField();
            if (!!inputField)
            {
                inputField.MoveTextEnd(false);
                return(true);
            }

            return(false);
        }
Пример #6
0
        public StaticAction(int id, string label, uint eventMask = 0, bool hidden = false)
        {
            if (id < 0 || id > 65535)
            {
                throw new System.ArgumentException("StaticAction.StaticAction: ID out of range: " + id);
            }

            m_ID        = id;
            m_Label     = label;
            m_EventMask = eventMask;
            m_Hidden    = hidden;
            StaticAction.RegisterAction(this);
        }
Пример #7
0
 public static void RegisterAction(StaticAction action)
 {
     s_Actions.Add(action);
 }