| Ticket UUID: | 2830360 | |||
| Title: | ttk::entry loses state invalid at focus events | |||
| Type: | Bug | Version: | obsolete: 8.6b1.1 | |
| Submitter: | cmi5 | Created on: | 2009-07-31 14:55:35 | |
| Subsystem: | 88. Themed Tk | Assigned To: | fvogel | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2020-01-18 12:13:51 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2020-01-18 12:13:51 | |||
| Description: |
Platforms: Unix X11 and Windows
Example to reproduce
% pack .e
% bind .e <FocusIn> {puts "%W <FocusIn> %d: [.e state]"}
% bind .e <FocusOut> {puts "%W <FocusOut> %d: [.e state]"}
% bind .e <Return> {.e state invalid}
After pressing Return inside the field and focussing outside the entryfield,
the state invalid is lost.
It also happens if you set state invalid from the console and focus into the entryfield.
| |||
| User Comments: |
fvogel added on 2020-01-18 12:13:51:
Merged into core-8-6-branch and trunk. fvogel added on 2020-01-02 15:14:50: Non-regression test added (entry-10.1) in ttk/entry.test. This test fails before the fix and passes with the fix. fvogel added on 2020-01-02 15:01:27: This documentation for ttk::entry says the following:
So indeed your example shows that the widget behavior and its documentation do not match: the "invalid" state really is lost on FocusIn/FocusOut events, whereas no validation was requested. One can ask what use case this script is demonstrating, given that the "invalid" state is maintained internally by the ttk entry widget. However I believe this script is a trimmed down version of what could really happen when the user inputs text in the entry, the validation fails, and the user moves the focus away from the entry widget: suddenly the entry could get validated! So we have to fix this. Analyzing the source code, EntryEventProc() calls for a background revalidation EntryRevalidateBG() whenever it receives a FocusIn or FocusOut event. In EntryValidateChange(), this background revalidation occurs conditionally, depending notably on !EntryNeedsValidation(vmode, reason). In the example given, EntryNeedsValidation(vmode, reason) returns false because vmode is VMODE_NONE. Therefore no validation really occurs, but EntryValidateChange() nevertheless returns TCL_OK, which results in clearing the TTK_STATE_INVALID flag in EntryRevalidate(). The fix is therefore to check for EntryNeedsValidation(vmode, reason) in EntryRevalidateBG(), to prevent EntryRevalidate() from clearing the TTK_STATE_INVALID flag even when validation mode is "none". This is [a8ed6013]. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki