| Ticket UUID: | 4e2d985d4a73aa3f726f54dd184df97ca44e5fcd | |||
| Title: | Tcl odd if statement syntax doesn't always work. | |||
| Type: | Bug | Version: | 8.6.8 | |
| Submitter: | bll | Created on: | 2018-09-03 17:50:24 | |
| Subsystem: | 88. Themed Tk | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2018-09-04 20:06:43 | |
| Resolution: | Rejected | Closed By: | bll | |
| Closed on: | 2018-09-04 20:06:43 | |||
| Description: |
Reference: https://groups.google.com/d/topic/comp.lang.tcl/5Gyb2fPy4lo/discussion
Can the library/ttk/*.tcl code please be updated to change all if statements
with the following syntax:
$cb instate disabled { return }
to:
if { [$cb instate disabled] } { return }
.e.g. ttk::combobox Post() routine
| |||
| User Comments: |
bll added on 2018-09-04 20:06:43:
Well, it's not a mistake.
The { return } script cannot be executed by an uplevel, so that code
in ttk::combobox will not work when wrapped up in a megawidget.
I've given up.
I'm just patching my Tcl/Tk code.
fvogel added on 2018-09-04 19:43:34: Bugfix branch closed without merge. Dubious between doing this and tagging it as a mistake but anyway... bll added on 2018-09-04 14:22:03: Looks like uplevel cannot correctly process a return statement. bll added on 2018-09-03 20:40:01: Oh, just re-reading what you wrote. I thought it was a weird syntax, no idea it was part of the instate command. So then because I have a wrapper around the ttk::combobox script, it is probably return-ing to the wrong level???? bll added on 2018-09-03 20:36:28: I really don't think 'instate' has a problem.
I think the 'expr { return }' is the problem.
Changing it to: if { expr } {return} fixes it.
Of course it could still be my code is trashing something, somehow...
But my code is not that complicated.
fvogel added on 2018-09-03 20:23:40: State matching is defined in a #define Ttk_StateMatches fvogel added on 2018-09-03 20:19:15: (...with a little help from dkf in the chat...) This syntax is documented as follows:
pathName instate statespec ?script?
Test the widget's state. If script is not specified, returns 1 if the widget state matches statespec and 0 otherwise. If script is specified, equivalent to
if {[pathName instate stateSpec]} script
This syntax shall work as documented, if it does not then we should fix it. Changing this to "if {...} {...}" can only be a workaround. dkf suggests we investigate what exactly "state matches" means in the above description. bll added on 2018-09-03 18:17:33: Here is my test code:
package require Tk
source cboxadj.tcl
cboxadj .cb -values {aa bb cc} -state readonly
cboxadj .cb2 -values {aa bb cc} -state disabled
pack .cb
pack .cb2
bll added on 2018-09-03 18:11:50: Bug branch: bug-4e2d985d4a73aa3f bll added on 2018-09-03 18:03:10: Also appears in ttk::button | |||
Attachments:
- cboxadj.tcl [download] added by bll on 2018-09-03 18:17:06. [details]
