Repository navigation
ValidatedEntryBox: validate as the value changes - #273
Conversation
Validation only ran on focus out and Return, so a success tick stayed while an invalid value was typed. The entry now validates on every change (an empty optional entry shows no mark). validate_on_change=False keeps the old behaviour. Closes #271 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SimosManiatis
left a comment
There was a problem hiding this comment.
I ran the tests locally (Py 3.13 and 3.10): all 5 in test_bhom_tkinter_ui.py pass.
1.Clearing an optional field doesn't call on_validate(True). Type abc, then delete it: on_validate gets False and never True, so a caller that enables Submit from it stays stuck. Could the empty-optional branch in _on_value_change also call _call_validate_callback(True)?
2.The empty optional tick comes back on focus out. Live typing clears both marks, but validate() (focus out / Return) still shows ✓ for an empty optional entry. Worth making the two consistent, probably in validate().
3.Errors appear mid-typing (-, or 5 on the way to 50 with min 10). Fine if intended. Alternatively, show the tick live but only show errors after a short pause or on focus out.
Live validation now only clears a stale success mark and reports validity to on_validate; errors show on focus out / Return. Clearing an optional entry reports valid, and validate() no longer ticks an empty optional entry. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
SimosManiatis
left a comment
There was a problem hiding this comment.
So all good nothing major but take a look at these below:
1.Clearing an optional field now goes through the empty branch in validate(), which calls _call_validate_callback(True). After an invalid value, set("") reports valid, so a Submit button driven by on_validate can turn back on.
2.That branch calls clear_error() instead of _show_success(). Focus out and Return leave an empty optional entry with neither mark, same as live typing.
3.An invalid value drops the tick straight away and on_validate gets False. The error label stays blank until focus out or Return, which is the option from the last review.
|
@BHoMBot check ready-to-merge |
|
@Felix-Mallinder to confirm, the following actions are now queued:
There are 7 requests in the queue ahead of you. |
Issues addressed by this PR
Closes #271
ValidatedEntryBoxonly validated on focus out and Return, so a success tick from an earlier value stayed while an invalid value was typed, and the error only showed on submit.validate_on_changeargument (defaultTrue);Falsekeeps the old behaviour.Test files
Python_Engine/Python/tests/test_bhom_tkinter_ui.py::test_widget_validation(new live and opt-out cases). All 5 tests in the file pass.Changelog
ValidatedEntryBoxvalidates as the value is typed; addedvalidate_on_changeto opt out.Additional comments
Note that
on_validatecallbacks now fire on each keystroke rather than only on focus out.🤖 Generated with Claude Code