Tk Source Code

View Ticket
Login
Ticket UUID: a53a902ac6e179ab41a650f8d97c5124f99f37db
Title: overrideredirect on linux/mac prevents certain binds from working
Type: Bug Version: 8.6.1, 8.6.6
Submitter: anonymous Created on: 2016-08-25 18:02:52
Subsystem: 01. Bindings Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2016-08-28 11:59:29
Resolution: None Closed By: nobody
    Closed on:
Description:
Keypress and other bindings do not work in a window with overrideredirect on mac and linux.

See:

http://stackoverflow.com/questions/34582637/tkinters-overrideredirect-prevents-certain-events-in-mac-and-linux

If I comment out the overrideredirect in the code below, and use the following
configuration with the devilspie program to create an undecorated window, then the keypress bindings work:
I have only tested on Linux.

(if (is (application_name) "t.tcl")
   (begin (undecorate)(below)(geometry "+100+100")))

#!/usr/bin/env wish
wm title . t.tcl
wm overrideredirect . True
wm geometry . "399x25+100+300"
bind . <KeyPress> {+puts "<KeyPress %K>"}
bind . <Button-1> {puts "<Button-1>"}
bind . <Enter> {puts "<Enter>"}
bind . <Leave> {puts "<Leave>"}
bind . <FocusIn> {puts "<FocusIn>"}
bind . <FocusOut> {puts "<FocusOut>"}
User Comments: pspjuth added on 2016-08-28 11:59:29:
A window with overrideredircct is deliberately prevented from taking focus, and thus cannot get key events:
http://core.tcl.tk/tk/artifact/7892c68f49012d2d71222ae0e312a1e7dc69a801?txt=1&ln=51-64

That line and comment is ancient, and might be possible to remove.
Not sure though.