public void Update(GameTime gameTime) { if (IsVisible) { if (HasFocus) { if (ControlMgr.Instance.PressedKeys.Count > 0) { if (ControlMgr.Instance.PressedKeys[0] == Keys.Back) { if (Text.Length > 0) { Text = Text.Remove(Text.Length - 1, 1); } } else if (ControlMgr.Instance.PressedKeys[0] == Keys.Delete) { Text = string.Empty; } else if (Text.Length < MaxLength) { switch (TextFilter) { case eTextFilter.None: foreach (Keys k in InputMgr.Instance.Keyboard.GetAllReleasedKeys()) { Text += InputMgr.KeyToString(k); } break; case eTextFilter.OnlyIntAndNeg: // Allow minus character if (ControlMgr.Instance.PressedKeys[0] == Keys.OemMinus && TextFilter != eTextFilter.OnlyIntOnlyPos) { Text += MINUS; } if (ControlMgr.Instance.PressedKeys[0] >= Keys.D0 && ControlMgr.Instance.PressedKeys[0] <= Keys.D9) { Text += ControlMgr.Instance.PressedKeys[0].ToString().Substring(1, 1); } break; case eTextFilter.OnlyIntOnlyPos: if (ControlMgr.Instance.PressedKeys[0] >= Keys.D0 && ControlMgr.Instance.PressedKeys[0] <= Keys.D9) { Text += ControlMgr.Instance.PressedKeys[0].ToString().Substring(1, 1); } break; case eTextFilter.OnlyNumericAndAlpha: if (ControlMgr.Instance.PressedKeys[0] == Keys.OemMinus && TextFilter != eTextFilter.OnlyIntOnlyPos) { if (InputMgr.Instance.ShiftIsDown) { Text += ControlMgr.Instance.PressedKeys[0].ToString(); } else { Text += ControlMgr.Instance.PressedKeys[0].ToString().ToLower(); } } if (ControlMgr.Instance.PressedKeys[0] >= Keys.D0 && ControlMgr.Instance.PressedKeys[0] <= Keys.D9) { Text += ControlMgr.Instance.PressedKeys[0].ToString().Substring(1, 1); } if (ControlMgr.Instance.PressedKeys[0] >= Keys.A && ControlMgr.Instance.PressedKeys[0] <= Keys.Z) { if (InputMgr.Instance.ShiftIsDown) { Text += ControlMgr.Instance.PressedKeys[0].ToString(); } else { Text += ControlMgr.Instance.PressedKeys[0].ToString().ToLower(); } } if (AllowSpace && ControlMgr.Instance.PressedKeys[0] == Keys.Space) { Text += " "; } break; case eTextFilter.OnlyAlpha: if (ControlMgr.Instance.PressedKeys[0] >= Keys.A && ControlMgr.Instance.PressedKeys[0] <= Keys.Z) { if (InputMgr.Instance.ShiftIsDown) { Text += ControlMgr.Instance.PressedKeys[0].ToString(); } else { Text += ControlMgr.Instance.PressedKeys[0].ToString().ToLower(); } } if (AllowSpace && ControlMgr.Instance.PressedKeys[0] == Keys.Space) { Text += " "; } break; default: throw new CaseStatementMissingException(); } } } } else { if (LostFocus != null && HadFocus) { LostFocus(this); } } HadFocus = HasFocus; } }