| Ticket UUID: | 1520118 | |||
| Title: | -validate set to none incorrectly | |||
| Type: | Bug | Version: | obsolete: 8.4.13 | |
| Submitter: | kelan | Created on: | 2006-07-10 18:02:00 | |
| Subsystem: | 17. [spinbox] | Assigned To: | fvogel | |
| Priority: | 6 | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2015-10-22 21:55:49 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2015-10-22 21:55:49 | |||
| Description: |
If -from and -to are set, -validate is reset to 'none'
when -validatecommand returns false.
-invalidatecommand is never evaluated.
Test case:
proc test {} {
puts "test"
return 0
}
pack [spinbox .works -validate all -vcmd test -invcmd
{puts "invalid"}]
pack [spinbox .broken -from 1 -to 10 -validate all
-vcmd test -invcmd {puts "invalid"}]
Try typing in both. The top one should trigger the
validation on every keypress. The bottom one won't do
anything because -validate was reset to 'none' when the
window was created.
| |||
| User Comments: |
fvogel added on 2015-10-22 21:55:49:
Merged to core-8-5-branch and trunk. Closing. fvogel added on 2015-10-16 20:50:36: Documentation update proposed in branch bug-1520118fff. fvogel added on 2015-10-15 19:32:14: This behaviour is intentional.
In the source code (tkEntry.c, see function EntryValidateChange), there is the following comment:
/*
* If we were doing forced validation (like via a variable trace) and
* the command returned 0, the we turn off validation because we
* assume that textvariables have precedence in managing the value.
* We also don't call the invcmd, as it may want to do entry
* manipulation which the setting of the var will later wipe anyway.
*/
What happens is the following:
- default values for -to and -from are 0 (zero), and the default value for the spinbox string is {}
- setting -to or -from such that the value of the spinbox string needs to get changed from the default empty value triggers a validation of the new value if -validatecommand is not empty
- if the validation script returns false, then (as per the comment pasted above) -validate is set to none and -invalidatecommand is not called.
The reason behind this is believed in the spinbox design that the textvariable associated with the spinbox shall take precedence over validation in managing the spinbox string. This is (a bit crypticly, OK...) documented at the bottom of the 'Validation' section of the spinbox man page.
Thus, this is not really a bug.
At this stage, we could do either of two things:
1. prevent forced validation to happen in the above mentioned case, but only when -textvariable is {} (and not change the behavior when it is set)
2. document this a bit better, without changing the source code
I'm not a big fan of proposal 1. because of the behavior change it implies. It could break existing scripts in the wild.
Therefore let's go for proposal 2.
kelan added on 2006-07-11 01:08:40: Logged In: YES user_id=379669 I forgot the "console show" line. You'll need that to see the output from the test proc. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki