/// <summary> /// Binds the left and right buttons to next and previous. /// </summary> private void BindGestures() { Gestures.Bind(PreviousOption, new ButtonPressed(Buttons.DPadLeft), new ButtonPressed(Buttons.LeftThumbstickLeft), new KeyPressed(Keys.Left)); Gestures.Bind(NextOption, new ButtonPressed(Buttons.DPadRight), new ButtonPressed(Buttons.LeftThumbstickRight), new KeyPressed(Keys.Right)); }
/// <summary> /// Binds menu navigation to the up and down keys. /// Override this to implement different behavier. /// </summary> private void BindGestures() { Gestures.Bind(PreviousOption, new ButtonPressed(Buttons.DPadUp), new ButtonPressed(Buttons.LeftThumbstickUp), new KeyPressed(Keys.Up)); Gestures.Bind(NextOption, new ButtonPressed(Buttons.DPadDown), new ButtonPressed(Buttons.LeftThumbstickDown), new KeyPressed(Keys.Down)); }
//void MenuOption_HotChanged(Control sender) //{ // if (IsWarm && (Parent != null && Parent.IsFocused)) UserInterface.Actors.AllFocus(this); //} /// <summary> /// Binds the A and Enter buttons to select. /// </summary> private void BindGestures() { Gestures.Bind(Select, new ButtonPressed(Buttons.A), new KeyPressed(Keys.Enter)); Gestures.Bind(MouseDown, new MousePressed(MouseButtons.Left)); Gestures.Bind(MouseUp, new MousePressed(MouseButtons.Left)); WarmChanged += c => { if (!IsWarm) { mouseDown = false; } }; }
protected void BindGestures() { Gestures.Bind(delegate(IGesture gesture, GameTime gameTime, IInputDevice device) { if (textBox.Text.Length > 0) { commandStack.PushCommand(textBox.Text); log.WriteLine(">" + textBox.Text); var result = engine.Execute(textBox.Text); if (result.Result != null) { log.WriteLine(result.Result.ToString()); } else if (result.Error != null) { log.WriteLine(result.Error); } } textBox.Text = ""; }, new KeyPressed(Keys.Enter)); Gestures.Bind(OnAutocomplete, new KeyPressed(Keys.Tab)); }
public TextBox(Control parent, Game game, SpriteFont font, string title, string description) : base(parent) { this.textString = string.Empty; this.text = new StringBuilder(); this.textString = ""; this.typing = false; this.title = title; this.description = description; this.drawBuffer = new StringBuilder(); this.font = font; this.colour = Color.White; this.drawStartIndex = 0; this.drawEndIndex = 0; this.blink = new Pulser(PulserType.SquareWave, TimeSpan.FromSeconds(0.5)); this.keyRepeat = new Pulser(PulserType.Simple, TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(0.5)); this.selectionStartIndex = 0; this.selectionEndIndex = 0; this.measurementBuffer = new StringBuilder(); this.blank = new Texture2D(game.GraphicsDevice, 1, 1); this.blank.SetData(new Color[] { Color.White }); this.IgnoredCharacters = new List <char>(); base.SetSize(100, font.LineSpacing); Gestures.Bind((g, t, i) => { i.Owner.Focus(this); BeginTyping(i.Owner.ID < 4 ? (PlayerIndex)i.Owner.ID : PlayerIndex.One); }, new ButtonPressed(Buttons.A), new MousePressed(MouseButtons.Left)); Gestures.Bind((g, t, i) => { var keyboard = i as KeyboardDevice; foreach (var character in keyboard.Characters) { Write(character.ToString()); } }, new CharactersEntered()); Gestures.Bind((g, t, i) => Copy(), new KeyCombinationPressed(Keys.C, Keys.LeftControl), new KeyCombinationPressed(Keys.C, Keys.RightControl)); Gestures.Bind((g, t, i) => Cut(), new KeyCombinationPressed(Keys.X, Keys.LeftControl), new KeyCombinationPressed(Keys.X, Keys.RightControl)); Gestures.Bind((g, t, i) => Paste(), new KeyCombinationPressed(Keys.V, Keys.LeftControl), new KeyCombinationPressed(Keys.V, Keys.RightControl)); FocusedChanged += control => { if (!IsFocused) { typing = false; } }; }