View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006424||JEDI VCL||00 JVCL Components||public||2015-07-28 15:41||2019-04-26 20:34|
|Target Version||Fixed in Version|
|Summary||0006424: TJvValidateEdit only enforces min/max if losing focus|
|Description||TJvValidateEdit performs its min and max value validation as part of its FocusKilled (WM_KILLFOCUS) handler. However, as explained by Raymond Chen in http://blogs.msdn.com/b/oldnewthing/archive/2004/04/19/115912.aspx, this is the wrong place to do validation. In particular, pressing Enter to close a dialog with an OK button never triggers FocusKilled, so TJvValidateEdit.Value can have an invalid value if it's read during the OK button's Click event.|
The best fix I can think of is for reading the Value property to trigger the same canonicalize-and-validate logic that FocusKilled does. This should only happen during normal runtime, so I believe this should only be done if ComponentState does not include csDesigning or csWriting.
Does this sound reasonable? Are there potential issues or complications that I'm missing? If so, I can submit a pull request.
|Tags||No tags attached.|
||Please provide the zipped sources of a sample application showing this|
JvValidateEdit.zip (4,995 bytes)
1. Run the attached sample application.
2. Click the Test button to open the modal dialog.
3. Enter a value of -1, which is below the configured MinValue of 0.
4. *Click* the OK button. Note that the message box displays the correctly enforced minimum value of 0, and the edit is set back to 0.
5. Click the Test button again to reopen the modal dialog.
6. Reenter a value of -1.
7. Without clicking anywhere or changing the keyboard focus, *press Enter* to activate the default OK button. Note that the message box displays an invalid value of -1, although the edit is set back to 0.
||I'd say your description and how you plan to fix it is worth a try! Please create that pull request suggested!|
|2015-07-28 15:41||jkelley||New Issue|
|2015-09-14 11:27||obones||Note Added: 0021196|
|2015-09-14 11:27||obones||Status||new => feedback|
|2015-09-14 22:14||jkelley||File Added: JvValidateEdit.zip|
|2015-09-14 22:16||jkelley||Note Added: 0021207|
|2015-09-15 09:30||obones||Status||feedback => acknowledged|
|2019-04-26 20:34||mh||Note Added: 0021753|