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: aku
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-16 16:44:57
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-10-16 16:11:19
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.

User Comments: serhiy.storchaka added on 2026-10-16 16:44:57:

Backported to core-8-6-branch in [cb6a83e591].


nemethi (claiming to be Csaba Nemethi) added on 2026-10-16 16:11:19:

Merged by Jan into main and core-9-0-branch by commits [60e87d28] and [00a12262]. Closing the ticket.