Tk Source Code

View Ticket
Login
Ticket UUID: c9f675856877740cf14d12a6ec83631c0c3cf097
Title: Middle-click paste focuses a spinbox only when it is disabled
Type: Bug Version: 8.6.18, 9.0.5, 9.1.0
Submitter: serhiy.storchaka Created on: 2026-10-08 20:16:40
Subsystem: 17. [spinbox] Assigned To:
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-10-08 20:16:40
Resolution: None Closed By:
    Closed on:
Description:

Pasting the PRIMARY selection with the middle mouse button into an entry gives the entry the focus, unless the entry is disabled. For a spinbox it is the opposite: a normal spinbox does not get the focus, and a disabled spinbox does (nothing is pasted into it).

spinbox .s; pack .s; button .b; pack .b
focus -force .b
event generate .s <<PasteSelection>> -x 5 -y 5
focus    ;# .b, but .s for an entry

The condition in tk::spinbox::Paste is inverted. When the spinbox was added in [73da332473], the code was copied from tkEntryPaste, which used [string compare "disabled" ...] (true if not equal), and was translated to [string equal "disabled" ...].

Proposed fix in branch spinbox-paste-focus, with tests spinbox-27.1 and entry-26.1.