Code: Select all
//
// code generated by DialogBlocks: m_TxtControl is the member variable for the text edit control
m_TxtControl = new wxTextCtrl( itemPanel1, ID_MY_TEXT_CONTROL, wxEmptyString, wxDefaultPosition, wxSize(40, -1), 0 );
...
// my code: m_fVal is a floating point variable
m_TxtControl->SetValidator(wxFloatingPointValidator<float>(1, &m_fVal, wxNUM_VAL_NO_TRAILING_ZEROES));
static_cast<wxFloatingPointValidator<float> *>(m_TxtControl ->GetValidator())->SetRange(0.1f, 1000.0f);
One: If the user wants to enter a valid number like 0.3 and starts by typing "0", the system dings as soon as the "0" is keyed in. If the first character entered is the decimal point ".", then entry can continue. But this is not very friendly - I think most of my users would expect to be able to enter a number less than 1 but greater than 0 by starting with "0.".
Two: if the user does start with "." to avoid the ding, but the enters ".1" it again fails, even though this should be within the allowed range. Looking at the source under debug, I think the problem is that the validator is checking:
Code: Select all
return m_min <= value && value <= m_max;
Does anyone have any thoughts about this? Is there something simple that I am missing? The failure to allow data entry starting with a 0 is a bit of a deal-breaker in terms of using this validator, at the moment.