View Issue Details

IDProjectCategoryView StatusLast Update
0006424JEDI VCL00 JVCL Componentspublic2019-04-26 20:34
ReporterjkelleyAssigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version3.47 
Target VersionFixed in Version 
Summary0006424: TJvValidateEdit only enforces min/max if losing focus
DescriptionTJvValidateEdit 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.
TagsNo tags attached.

Activities

obones

2015-09-14 11:27

administrator   ~0021196

Please provide the zipped sources of a sample application showing this

2015-09-14 22:14

 

JvValidateEdit.zip (4,995 bytes)

jkelley

2015-09-14 22:16

reporter   ~0021207

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.

mh

2019-04-26 20:34

reporter   ~0021753

I'd say your description and how you plan to fix it is worth a try! Please create that pull request suggested!

Issue History

Date Modified Username Field Change
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