Summary description for KeyPressEventArgs.
Inheritance: EventArgs
Esempio n. 1
0
        private static void KeyTypedClass(Actor sender, KeyCharEventArgs e)
        {
            TextField field = sender as TextField;

            if (field != null)
            {
                field.OnKeyTyped(e);
            }
        }
Esempio n. 2
0
        public override bool KeyChar(KeyCharEventArgs e)
        {
            switch (e.Key)
            {
            default:
                _text = _text.Insert(_cursorPos, e.Character.ToString());
                _cursorPos++;
                break;
            }

            return(true);
        }
Esempio n. 3
0
 public void FireKeyChar(KeyCharEventArgs e)
 {
     KeyChar?.Invoke(this, e);
 }
Esempio n. 4
0
 public override bool KeyChar(KeyCharEventArgs e)
 {
     return(_currentScene?.KeyChar(e) ?? false);
 }
Esempio n. 5
0
 public virtual void OnKeyPress(KeyCharEventArgs kpe)
 {
 }
Esempio n. 6
0
 public virtual bool KeyChar(KeyCharEventArgs e)
 {
     return(false);
 }
Esempio n. 7
0
        protected virtual void OnKeyTyped(KeyCharEventArgs e)
        {
            if (IsDisabled)
            {
                return;
            }

            BitmapFont font = _style.Font;

            Stage stage = Stage;

            if (stage != null && stage.GetKeyboardFocus() == this)
            {
                if (e.Character == CharBackspace)
                {
                    if (_cursor > 0 || _hasSelection)
                    {
                        if (!_hasSelection)
                        {
                            _text = _text.Substring(0, _cursor - 1) + _text.Substring(_cursor);
                            UpdateDisplayText();
                            _cursor--;
                            _renderOffset = 0;
                            OnTextChanged();
                        }
                        else
                        {
                            Delete();
                        }
                    }
                }
                else if (e.Character == CharDelete)
                {
                    if (_cursor < _text.Length || _hasSelection)
                    {
                        if (!_hasSelection)
                        {
                            _text = _text.Substring(0, _cursor) + _text.Substring(_cursor + 1);
                            UpdateDisplayText();
                            OnTextChanged();
                        }
                        else
                        {
                            Delete();
                        }
                    }
                }
                else if ((e.Character == CharTab || e.Character == CharEnterAndroid) && FocusTraversal)
                {
                    KeyboardState keyboard = Keyboard.GetState();
                    Next(keyboard.IsKeyDown(Keys.LeftShift) || keyboard.IsKeyDown(Keys.RightShift));
                }
                else if (font.ContainsCharacter(e.Character))
                {
                    if (e.Character != CharEnterDesktop && e.Character != CharEnterAndroid)
                    {
                        if (TextFieldFilter != null && !TextFieldFilter.AcceptChar(this, e.Character))
                        {
                            e.Handled = true;
                            return;
                        }
                    }

                    if (MaxLength > 0 && _text.Length + 1 > MaxLength)
                    {
                        e.Handled = true;
                        return;
                    }

                    if (!_hasSelection)
                    {
                        _text = _text.Substring(0, _cursor) + e.Character
                                + _text.Substring(_cursor, _text.Length - _cursor);
                        UpdateDisplayText();
                        _cursor++;
                        OnTextChanged();
                    }
                    else
                    {
                        int minIndex = Math.Min(_cursor, _selectionStart);
                        int maxIndex = Math.Max(_cursor, _selectionStart);

                        _text = (minIndex > 0 ? _text.Substring(0, minIndex) : "")
                                + (maxIndex < _text.Length ? _text.Substring(maxIndex, _text.Length - maxIndex) : "");
                        _cursor = minIndex;
                        _text   = _text.Substring(0, _cursor) + e.Character
                                  + _text.Substring(_cursor, _text.Length - _cursor);
                        OnTextChanged();

                        UpdateDisplayText();
                        _cursor++;
                        ClearSelection();
                    }
                }

                e.Handled = true;
            }
        }
Esempio n. 8
0
 protected virtual void OnPreviewKeyTyped(KeyCharEventArgs e)
 {
 }