Tk Source Code

View Ticket
Login
Ticket UUID: 99bb36df8687bf76f526c2816d901eb10f019577
Title: Slider trough click repeats if command creates modal dialogue
Type: Bug Version: 8.6.12
Submitter: jal_frezie Created on: 2022-01-20 17:25:19
Subsystem: 15. [scale] Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Severe
Status: Closed Last Modified: 2026-10-20 14:21:43
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2026-10-20 14:21:43
Description:
Set up a slider such that when it is moved a modal dialogue is generated. Simplest way to do this is have its command generate an error message, e.g.,

package require Tk
pack [scale .s -length 1000 -command foo]

(note that foo is intentionally undefined). Now when you drag the slider, it will produce an error message, and when you OK that, the slider will have moved a little, and you can do again. But, if you click in the trough either side of the slider, it will move gradually all the way to the end of the scale producing what appear to be a lot of superimposed error dialogues. Note this doesn't just happen with error messages, showing any modal dialogue (using wm transient and grab) in the command associated with the slider will have the same effect.

Repeated on Windows, Linux and MacOS. Expected behaviour is for the message to appear once and the slider to move one step in the appropriate direction.
User Comments: jan.nijtmans added on 2026-10-20 14:21:43:

Merge to [bc3442af|trunk], core-9-0-branch and core-8-6-branch

Many thanks!


serhiy.storchaka added on 2026-10-20 11:39:07:

Thank you, Jan! event-9.18 is a known failure on macOS, not related to this fix. Marc wrote in [40dc19ee9e] that branch tip_765 fixes the failures of event-9.11–9.20 on macOS. It passes on X11.


jan.nijtmans added on 2026-10-20 11:20:04:

> does scale-23.1 pass on macOS with it?

Yes, it passes. So I merged your fix.

There was another failure, but that's unrelated to scale.test:

event.test
==== event-9.18 Successive destructions (pointer window + ancestors including its toplevel), destination is non-root toplevel FAILED
==== Contents of test case:
    bind all <Leave> {append result "<Leave> %d %W|"}
    bind all <Enter> {append result "<Enter> %d %W|"}
    destroy .two
    waitForWindowEvent .one <Enter>
    set result
---- Test setup failed:
wait for <Enter> event on .two.f1.f2 timed out (> 100 ms)
---- errorInfo(setup): wait for <Enter> event on .two.f1.f2 timed out (> 100 ms)
    while executing
"waitForWindowEvent .two.f1.f2 <Enter>"
    ("uplevel" body line 8)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): NONE
==== event-9.18 FAILED


serhiy.storchaka added on 2026-10-20 07:16:58:

I think the test found another bug, [ea459e12c2]: the scale's -command is called again with the same value if the scale is redrawn while the command is running. In scale-23.1 the command waits in tkwait window .d; on macOS mapping the dialog probably redraws the scale, so the command is called a second time. On X11 the scale is not redrawn, and the test passes.

Proposed fix in branch scale-command-redraw. Marc, does scale-23.1 pass on macOS with it?


marc_culler (claiming to be Marc Culler) added on 2026-10-20 03:54:48:
I am re-opening this because I am seeing consistent failures of the
scale-23.1 test with Tk 9.1 on macOS 27 (with Retina display, although
that does not seem relevant here).

The scale does not have the behavior described in the ticket;
I only get one error dialog. But the test fails.  I get:

==== scale-23.1 trough click repeat stops when the command grabs - Bug [99bb36df86] FAILED
==== Contents of test case:

    set y [lindex [.s coords] 1]
    event generate .s <Button-1> -x 350 -y $y
    after 50 [list event generate .s <ButtonRelease-1> -x 350 -y $y]
    pause 1000
    set count

---- Result was:
2
---- Result should have been (exact matching):
1
==== scale-23.1 FAILED

Maybe the test needs a little adjustment?

jan.nijtmans added on 2026-10-07 08:21:04:

Fixed in [706fc3f60d132782|trunk], core-9-0-branch and core-8-6-branch


serhiy.storchaka added on 2026-09-18 21:25:37:

With a grab set by the modal dialog while the button is down, the button release goes to the grab window and never cancels the repeat. Fix in branch [c8f931cb9c].


fvogel added on 2022-01-20 21:17:07:

Rings a bell. Perhaps linked to [415415ffff], or an effect of the same root cause?