public bool AcceptChar(TextField textField, char c) { // only allow one . if (c == '.') { return(!textField.GetText().Contains(".")); } return(Char.IsDigit(c) || c == '-'); }
void OnButtonClicked(Button button) { if (_parameterType == null) { (_memberInfo as MethodInfo).Invoke(_target, new object[] { }); } else { // extract the param and properly cast it var parameters = new object[1]; try { if (_parameterType == typeof(float)) { parameters[0] = float.Parse(_textField.GetText()); } else if (_parameterType == typeof(int)) { parameters[0] = int.Parse(_textField.GetText()); } else if (_parameterType == typeof(bool)) { parameters[0] = bool.Parse(_textField.GetText()); } else { parameters[0] = _textField.GetText(); } (_memberInfo as MethodInfo).Invoke(_target, parameters); } catch (Exception e) { Debug.Error(e.ToString()); } } }