Tk Source Code

View Ticket
Login
2018-09-04
20:06 • Ticket [4e2d985d] Tcl odd if statement syntax doesn't always work. status still Closed with 5 other changes artifact: 75aa575c user: bll
19:43 • Ticket [4e2d985d]: 5 changes artifact: 94eea170 user: fvogel
14:22 • Closed ticket [4e2d985d]. artifact: f763abc8 user: bll
2018-09-03
20:40 • Ticket [4e2d985d]: 3 changes artifact: 22515094 user: bll
20:36 • Ticket [4e2d985d]: 3 changes artifact: b2275e11 user: bll
20:23 • Ticket [4e2d985d]: 3 changes artifact: 601f99ae user: fvogel
20:19 • Ticket [4e2d985d]: 3 changes artifact: 3f2d24c5 user: fvogel
18:17 • Ticket [4e2d985d]: 3 changes artifact: 5e8e2c24 user: bll
18:17 • Add attachment cboxadj.tcl to ticket [4e2d985d] artifact: 80986096 user: bll
18:11 • Ticket [4e2d985d] Tcl odd if statement syntax doesn't always work. status still Open with 3 other changes artifact: 72f7d88f user: bll
18:10
Change syntax of 'instate' to a regular if statement. See [4e2d985d4a] and discussion on comp.lang.tcl (pointer is in the ticket). closed check-in: 5743bd56 user: bll tags: bug-4e2d985d4a
18:03 • Ticket [4e2d985d] Tcl odd if statement syntax doesn't always work. status still Open with 3 other changes artifact: 5ce9daed user: bll
17:50 • New ticket [4e2d985d]. artifact: ceab65d6 user: bll

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: