protected override void DrawSelf(SpriteBatch spriteBatch) { base.DrawSelf(spriteBatch); //Rectangle hitbox = GetInnerDimensions().ToRectangle(); //Main.spriteBatch.Draw(Main.magicPixel, hitbox, Color.Red * 0.6f); if (Focused) { Terraria.GameInput.PlayerInput.WritingText = true; Main.instance.HandleIME(); string newString = Main.GetInputText(CurrentString); if (!newString.Equals(CurrentString)) { CurrentString = newString; OnTextChange?.Invoke(this); } else { CurrentString = newString; } if (JustPressed(Keys.Tab)) { if (UnfocusOnTab) { Focused = false; OnUnfocus?.Invoke(this); } OnTab?.Invoke(this); } if (++_textBlinkerCount >= 20) { _textBlinkerState = (_textBlinkerState + 1) % 2; _textBlinkerCount = 0; } } string displayString = CurrentString; if (_textBlinkerState == 1 && Focused) { displayString += "|"; } CalculatedStyle space = GetDimensions(); if (CurrentString.Length == 0 && !Focused) { Vector2 vector = Main.fontMouseText.MeasureString(_hintText); Utils.DrawBorderString(spriteBatch, _hintText, new Vector2(space.X + 6, space.Y + Height.Pixels - vector.Y - 5), Color.Gray); } else { Vector2 vector = Main.fontMouseText.MeasureString(displayString); Utils.DrawBorderString(spriteBatch, displayString, new Vector2(space.X + 6, space.Y + Height.Pixels - vector.Y - 5), Color.White); } }
public virtual bool NewInput(MyConsoleKeyInfo KeyInfo) { switch (KeyInfo.KeyChar) { case (char)SpecialAsciiKeys.Tab: OnTab?.Invoke(this, DateTime.Now); return(true); case '\n': OnAccept?.Invoke(this, DateTime.Now); return(true); } return(false); }
protected override void DrawSelf(SpriteBatch spriteBatch) { //base.DrawChildren(spriteBatch); if (focused) { PlayerInput.WritingText = true; Main.instance.HandleIME(); string inputText = Main.GetInputText(currentText); if (!inputText.Equals(currentText)) { currentText = inputText; OnTextChange?.Invoke(this, new EventArgs()); } else { currentText = inputText; } if (JustPressed(Keys.Tab)) { if (unfocusOnTab) { focused = false; OnUnfocus?.Invoke(this, new EventArgs()); } OnTab?.Invoke(this, new EventArgs()); } if (++textBlinkerCount >= 20) { textBlinkerState = (textBlinkerState + 1) % 2; textBlinkerCount = 0; } } string text = currentText; if (textBlinkerState == 1 && focused) { text += "|"; } DrawHint(spriteBatch, text); }