Tk Source Code

View Ticket
Login
Ticket UUID: 3119824
Title: Enter doesn't work in text input box
Type: Bug Version: obsolete: 8.4.16
Submitter: alsuren Created on: 2010-11-26 16:57:42
Subsystem: 18. [text] Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2024-12-10 13:11:12
Resolution: None Closed By: nobody
    Closed on:
Description:
Sorry if this is in the wrong place: I'm assuming that it's your responsibility as a toolkit, but it might just be something stupid that client programs are doing.

git gui's Commit Message text input widget doesn't respond to the Enter key (on the keypad) but it responds to the Return key (on the main keboard area) fine.

I wonder whether this is a regression caused by fixing bugs 1233009 1327482 and 787402.

If this is in fact a git-gui bug (them failing to bind enter properly or something) or is fixed in the latest version of tk, I'm sorry for wasting your time.
User Comments: jan.nijtmans added on 2024-12-10 13:11:12:

See: TIP #158

Dup of [b3a1b9852de7859c]


fvogel added on 2016-08-15 14:13:40:

Easy patch at the application level is to add:

bind Text <KP_Enter> [bind Text <Return>] ; # Linux
bind Text <Extended-Return> [bind Text <Return>] ; # Windows, thanks to TIP #158


flatworm added on 2010-11-27 06:24:28:
Following up http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=605041 --

I tested this on my Debian Squeeze box.
xev reports Return for the regular Return key and KP_Enter for the keypad enter (so I was slightly wrong about the keysyms in my previous comment).
Now, the simplistic code (typed into tkcon, you can type it into wish as well):

% package require Tk
8.5.8
% text .t
.t
% pack .t
% bind Text <Return>

    tk::TextInsert %W \n
    if {[%W cget -autoseparators]} {
%W edit separator
    }

% bind Text <KP_Enter>
# nothing

This code shows two Return-related bindings on the "Text" "binding tag" -- it is assigned to all Tk text widgets.
"# nothing" here shows the text of a Tcl script bound to KP_Enter. This is a script consisting of one comment line.
Somewhat weird as no binding would be signalized by an empty string returned.

To round up: no action is bound to the keypad return key for Tk text widget in Tk 8.5.9 on X11.

flatworm added on 2010-11-27 00:56:29:
I've just checked this on Windows XP SP3 -- works for me in git-gui running Tcl/Tk 8.5.9 (from the latest stock msysgit beta installer), and also I checked this behaviour in vanilla Tcl/Tk runtimes (8.5.0, 8.5.8 and 8.6 CVS HEAD) I have on my system, and in all of them KP_Return seems to be bound by default to the same action as Return.

So I wonder: what OS and are you really using Tcl/Tk 8.4.16 (as mentioned in the Group setting for this bug)?