GetLastInputChar() public static method

Get last char from UnityEngine.Input.inputString.
public static GetLastInputChar ( ) : char
return char
Example #1
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            switch (e.KeyCode)
            {
            case Keys.Down:
            case Keys.Right:
                SelectItem(SelectedIndex + 1);
                break;

            case Keys.Left:
            case Keys.Up:
                SelectItem(SelectedIndex - 1);
                break;

            case Keys.PageDown:
                SelectItem(SelectedIndex + visibleItemsCount - 1);
                break;

            case Keys.PageUp:
                SelectItem(SelectedIndex - visibleItemsCount + 1);
                break;

            case Keys.Home:
                SelectItem(0);
                break;

            case Keys.End:
                SelectItem(Items.Count - 1);
                break;

            default:

                // Key filter.
                char c = KeyHelper.GetLastInputChar();
                if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
                {
                    keyFilter += char.ToLower(c);
                    var itemIndex = FindItemIndex(x => x != null && x.ToString().ToLower().StartsWith(keyFilter));
                    SelectItem(itemIndex);

                    if (keyTimer == null)
                    {
                        keyTimer          = new Timer();
                        keyTimer.Interval = keyFilterResetTime * 1000;
                        keyTimer.Tick    += (sender, args) => ResetKeyFilter();
                    }

                    keyTimer.Stop();
                    keyTimer.Start();
                }
                break;
            }
        }
Example #2
0
        protected override void OnKeyPress(KeyPressEventArgs args)
        {
            base.OnKeyPress(args);

            var e = args.uwfKeyArgs;

            if (e.Modifiers == Keys.None)
            {
                switch (e.KeyCode)
                {
                case Keys.Space:
                case Keys.Return:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Toggle();
                    }
                    break;

                case Keys.Down:
                    _SelectNext();
                    break;

                case Keys.Left:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Collapse();
                    }
                    break;

                case Keys.Right:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Expand();
                    }
                    break;

                case Keys.Up:
                    _SelectPrevious();
                    break;
                }
            }

            char c = KeyHelper.GetLastInputChar();

            if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
            {
                filter         += c;
                resetFilterTime = 3; // sec.
                SelectNodeWText(filter);
            }
        }
Example #3
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            switch (e.uwfKeyArgs.KeyCode)
            {
            case Keys.Down:
            case Keys.Right:
                SelectItem(SelectedIndex + 1);
                break;

            case Keys.Left:
            case Keys.Up:
                SelectItem(SelectedIndex - 1);
                break;

            case Keys.PageDown:
                SelectItem(SelectedIndex + visibleItemsCount - 1);
                break;

            case Keys.PageUp:
                SelectItem(SelectedIndex - visibleItemsCount + 1);
                break;

            case Keys.Home:
                SelectItem(0);
                break;

            case Keys.End:
                SelectItem(Items.Count - 1);
                break;

            default:

                // Key filter.
                char c = KeyHelper.GetLastInputChar();
                if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
                {
                    keyFilter += char.ToLower(c);
                    var itemIndex = FindItemIndex(x => x != null && x.ToString().ToLower().StartsWith(keyFilter));
                    SelectItem(itemIndex);

                    if (keyFilterIA == null)
                    {
                        keyFilterIA = Unity.API.UnityWinForms.Invoke(ResetKeyFilter, keyFilterResetTime);
                    }
                    keyFilterIA.Seconds = keyFilterResetTime;
                }
                break;
            }
        }
Example #4
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            base.OnKeyPress(e);

            var keyCode = e.uwfKeyArgs.KeyCode;

            switch (keyCode)
            {
            case Keys.Right: cursor.MoveRight(); return;
            }

            var lastChar = KeyHelper.GetLastInputChar();

            text[0] += lastChar;
        }
Example #5
0
        protected override void OnKeyPress(KeyEventArgs e)
        {
            base.OnKeyPress(e);
            if (e.Modifiers == UnityEngine.EventModifiers.None)
            {
                switch (e.KeyCode)
                {
                case UnityEngine.KeyCode.Space:
                case UnityEngine.KeyCode.Return:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Toggle();
                    }
                    break;

                case UnityEngine.KeyCode.DownArrow:
                    _SelectNext();
                    break;

                case UnityEngine.KeyCode.LeftArrow:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Collapse();
                    }
                    break;

                case UnityEngine.KeyCode.RightArrow:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Expand();
                    }
                    break;

                case UnityEngine.KeyCode.UpArrow:
                    _SelectPrevious();
                    break;
                }
            }

            char c = KeyHelper.GetLastInputChar();

            if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
            {
                _filter         += c;
                _resetFilterTime = 3; // sec.
                SelectNodeWText(_filter);
            }
        }
Example #6
0
        private static void RaiseKeyEvent(KeyEventArgs args, KeyEvents keyEventType, Control keyControl)
        {
            switch (keyEventType)
            {
            case KeyEvents.Down:
                keyControl.RaiseOnKeyDown(args);

                var lastChar = KeyHelper.GetLastInputChar();
                if (args.KeyCode == Keys.Space || args.KeyCode == Keys.Back || char.IsControl(lastChar) == false)
                {
                    keyControl.RaiseOnKeyPress(new KeyPressEventArgs(lastChar));
                }

                break;

            case KeyEvents.Up:
                keyControl.RaiseOnKeyUp(args);
                break;
            }
        }
Example #7
0
        private static void RaiseKeyEvent(KeyEventArgs args, KeyEvents keyEventType, Control keyControl)
        {
            switch (keyEventType)
            {
            case KeyEvents.Down:
                if (currentKeyDown == Keys.None || currentKeyDown != args.KeyCode)
                {
                    keyControl.RaiseOnKeyDown(args);
                }

                var pressArgs = new KeyPressEventArgs(KeyHelper.GetLastInputChar());
                pressArgs.uwfKeyArgs = args;

                keyControl.RaiseOnKeyPress(pressArgs);
                break;

            case KeyEvents.Up:
                currentKeyDown = Keys.None;
                keyControl.RaiseOnKeyUp(args);
                break;
            }
        }
Example #8
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            var keyCode  = e.KeyCode;
            var ctrlMod  = e.Control;
            var shiftMod = e.Shift;

            switch (keyCode)
            {
            // Basic navigation.
            case Keys.Down: CursorMoveDown(ctrlMod, shiftMod); return;

            case Keys.Left: CursorMoveLeft(ctrlMod, shiftMod); return;

            case Keys.Right: CursorMoveRight(ctrlMod, shiftMod); return;

            case Keys.Up: CursorMoveUp(ctrlMod, shiftMod); return;

            case Keys.End: cursor.MoveToLineEnd(); return;

            case Keys.Home: cursor.MoveToLineStart(); return;

            case Keys.Back: CursorRemoveTextToLeft(); return;

            case Keys.Delete: CursorRemoveTextToRight(); return;

            case Keys.Enter:
                lines.Insert(cursor.y + 1, "");
                cursor.MoveDown();
                return;
            }

            var lastChar = KeyHelper.GetLastInputChar();

            CursorInsertText(lastChar.ToString());
        }
Example #9
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            switch (e.KeyCode)
            {
            case Keys.Down:
            {
                if (Items.IsDisabled(selectedIndex + 1))
                {
                    break;
                }
                if (listBox != null)
                {
                    listBox.SelectedIndex++;
                    SelectedIndex = Items.FindIndex(x => x == listBox.SelectedItem);
                    listBox.EnsureVisible();
                }
                else if (selectedIndex + 1 < Items.Count)
                {
                    SelectedIndex++;
                }
            }
            break;

            case Keys.Up:
            {
                if (Items.IsDisabled(selectedIndex - 1))
                {
                    break;
                }

                if (listBox != null)
                {
                    listBox.SelectedIndex--;
                    if (listBox.SelectedIndex < 0 && listBox.Items.Count > 0)
                    {
                        listBox.SelectedIndex = 0;
                    }
                    SelectedIndex = Items.FindIndex(x => x == listBox.SelectedItem);
                    listBox.EnsureVisible();
                }
                else if (selectedIndex > 0)
                {
                    SelectedIndex--;
                }
            }
            break;

            case Keys.Return:
                if (listBox != null && !listBox.Disposing && !listBox.IsDisposed)
                {
                    listBox.SelectItem(listBox.SelectedIndex);
                    ApplySelectedItem();
                }
                break;
            }
            if (listBox != null && DropDownStyle == ComboBoxStyle.DropDownList)
            {
                if (keyFlag == true)
                {
                    keyFlag = false;
                    filter  = "";
                }

                char c = KeyHelper.GetLastInputChar();
                if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
                {
                    filter += char.ToLower(c);
                    var itemIndex = listBox.FindItemIndex(x => x != null && x.ToString().ToLower().Contains(filter));
                    if (itemIndex > -1)
                    {
                        listBox.SelectItem(itemIndex);
                    }
                }
            }
        }
Example #10
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.Modifiers == Keys.None)
            {
                switch (e.KeyCode)
                {
                case Keys.Space:
                case Keys.Return:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Toggle();
                    }
                    break;

                case Keys.Down:
                    SelectNext();
                    break;

                case Keys.Left:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Collapse();
                    }
                    break;

                case Keys.Right:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Expand();
                    }
                    break;

                case Keys.Up:
                    SelectPrevious();
                    break;

                case Keys.PageDown:
                    if (nodeList.Count > 0)
                    {
                        var lNodesOnScreen = nodesOnScreen;
                        var nextIndex      = 0;
                        if (SelectedNode != null)
                        {
                            nextIndex = nodeList.IndexOf(SelectedNode);
                        }
                        nextIndex    = MathHelper.Clamp(nextIndex + lNodesOnScreen, 0, nodeList.Count - 1);
                        SelectedNode = nodeList[nextIndex];
                    }
                    break;

                case Keys.PageUp:
                    if (nodeList.Count > 0)
                    {
                        var lNodesOnScreen = nodesOnScreen;
                        var nextIndex      = 0;
                        if (SelectedNode != null)
                        {
                            nextIndex = nodeList.IndexOf(SelectedNode);
                        }
                        nextIndex    = MathHelper.Clamp(nextIndex - lNodesOnScreen, 0, nodeList.Count - 1);
                        SelectedNode = nodeList[nextIndex];
                    }
                    break;

                case Keys.End:
                    if (nodeList.Count > 0)
                    {
                        SelectedNode = nodeList[nodeList.Count - 1];
                    }
                    break;

                case Keys.Home:
                    if (nodeList.Count > 0)
                    {
                        SelectedNode = nodeList[0];
                    }
                    break;
                }
            }
            else if (e.Control)
            {
                switch (e.KeyCode)
                {
                case Keys.Down:
                    if (uwfVScrollBar.Visible)
                    {
                        uwfVScrollBar.DoScroll(ScrollEventType.SmallIncrement);
                    }
                    break;

                case Keys.Up:
                    if (uwfVScrollBar.Visible)
                    {
                        uwfVScrollBar.DoScroll(ScrollEventType.SmallDecrement);
                    }
                    break;
                }
            }


            char c = KeyHelper.GetLastInputChar();

            if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
            {
                filter         += c;
                resetFilterTime = 3; // sec.
                SelectNodeWText(filter);
            }
        }
Example #11
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            switch (e.KeyCode)
            {
            case Keys.Down:
                SelectItem(SelectedIndexInternal + 1);
                break;

            case Keys.Left:
                if (DropDownStyle == ComboBoxStyle.DropDownList)
                {
                    SelectItem(SelectedIndexInternal - 1);
                }
                break;

            case Keys.Right:
                if (DropDownStyle == ComboBoxStyle.DropDownList)
                {
                    SelectItem(SelectedIndexInternal + 1);
                }
                break;

            case Keys.Up:
                SelectItem(SelectedIndexInternal - 1);
                break;

            case Keys.PageDown:
                SelectItem(SelectedIndexInternal + MaxDropDownItems);
                break;

            case Keys.PageUp:
                SelectItem(SelectedIndexInternal - MaxDropDownItems);
                break;

            case Keys.Home:
                SelectItem(0);
                break;

            case Keys.End:
                SelectItem(Items.Count);
                break;

            case Keys.Return:
                if (listBoxPanel != null && !listBoxPanel.Disposing && !listBoxPanel.IsDisposed)
                {
                    listBoxPanel.listBox.SelectItem(listBoxPanel.listBox.SelectedIndex);
                    ApplySelectedItem();
                }
                break;
            }

            if (listBoxPanel != null && DropDownStyle == ComboBoxStyle.DropDownList)
            {
                // Filter with key input.
                if (resetKeyFilter)
                {
                    resetKeyFilter = false;
                    keyFilter      = "";
                }

                char c = KeyHelper.GetLastInputChar();
                if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
                {
                    keyFilter += char.ToLower(c);
                    var itemIndex = listBoxPanel.listBox.FindItemIndex(x => x != null && x.ToString().ToLower().Contains(keyFilter));
                    if (itemIndex > -1)
                    {
                        listBoxPanel.listBox.SelectItem(itemIndex);
                    }
                }
            }
        }