Process() public méthode

Process the current keyboard state and add or remove characters from the given StringBuilder.
public Process ( KeyboardState keyboard, GameTime time, StringBuilder text ) : void
keyboard Microsoft.Xna.Framework.Input.KeyboardState /// The keyboard state input is being read from. ///
time Microsoft.Xna.Framework.GameTime /// Current GameTime. ///
text StringBuilder /// The StringBuilder to be modified based on keyboard state. ///
Résultat void
Exemple #1
0
        public bool HandleEvent(ISkinLayout skin, Rectangle layout, IGameContext context, Event @event)
        {
            var mousePressEvent = @event as MousePressEvent;
            var touchPressEvent = @event as TouchPressEvent;

            if (mousePressEvent != null && mousePressEvent.Button == MouseButton.Left)
            {
                if (layout.Contains(mousePressEvent.MouseState.X, mousePressEvent.MouseState.Y))
                {
                    this.Focus();

                    return(true);
                }
            }

            if (touchPressEvent != null)
            {
                if (layout.Contains((int)touchPressEvent.X, (int)touchPressEvent.Y))
                {
                    this.Focus();

#if PLATFORM_ANDROID
                    var manager = (InputMethodManager)Game.Activity.GetSystemService(Context.InputMethodService);
                    manager.ShowSoftInput(((Microsoft.Xna.Framework.AndroidGameWindow)context.Game.Window).GameViewAsView, ShowFlags.Forced);
#endif

                    return(true);
                }
                else
                {
#if PLATFORM_ANDROID
                    var manager = (InputMethodManager)Game.Activity.GetSystemService(Context.InputMethodService);
                    manager.HideSoftInputFromWindow(((Microsoft.Xna.Framework.AndroidGameWindow)context.Game.Window).GameViewAsView.WindowToken, HideSoftInputFlags.None);
#endif
                }
            }

            var keyEvent = @event as KeyboardEvent;

            if (keyEvent != null)
            {
                var keyboard = keyEvent.KeyboardState;
                if (Focused)
                {
                    _keyboardReader.Process(keyboard, context.GameTime, _textBuilder);
                    if (_textBuilder.ToString() != _previousValue)
                    {
                        TextChanged?.Invoke(this, new EventArgs());
                    }

                    _previousValue = _textBuilder.ToString();

                    return(true);
                }
            }

            return(false);
        }