Tk Source Code

View Ticket
Login
Ticket UUID: aa73806f6c4c3dd367feb1faf1f84d96895d0ff2
Title: Floating window freezes entry text
Type: Bug Version: 8.6.1
Submitter: anonymous Created on: 2016-04-19 11:46:30
Subsystem: 68. Win Window Operations Assigned To: fvogel
Priority: 6 Severity: Important
Status: Closed Last Modified: 2016-12-03 13:47:46
Resolution: Rejected Closed By: fvogel
    Closed on: 2016-12-03 13:47:46
Description:
Hi,

I have an entry and a button that creates a floating window, that contains only one close button. My OS is Windows.

In order to reproduce the problem, please run and test the code below like this:

1. Try to select something in the entry -> It will work
2. Press on the button to show the floating window -> A new toplevel will appear
3. Try to select something in the entry -> It will still work
4. Close the floating window and try to select again -> It won't work
5. Minimize and maximize the main toplevel and try to select again -> It will work again

Actually the text is selected but the selection is not visible...

Thanks
Alexandru

#-----------------------------------
# Run this code:
#-----------------------------------
set text "This text cannot be selected after the floating window is closed"
pack [ttk::entry .e -textvariable ::text] -expand 1 -fill x
pack [ttk::button .b -text "Show floating window" -command Show] -expand 1 -fill x

proc Show {} {
   # Make a floating window, always on top
   WindowFloating .tooltip 1
   # Add entry widget
   pack [ttk::button .tooltip.close -text "Close" -command "destroy .tooltip" -text close]
   wm geometry .tooltip +300+300
}

# Make a floating window
proc WindowFloating {w {ontop 0}} {
   # Toplevel window
   destroy $w
   toplevel $w -bd 1 -bg white -relief raised
   # Get screen dimensions
   set scrh [winfo screenheight [winfo parent $w]]    ;# 1) flashing window fix
   set scrw [winfo screenwidth [winfo parent $w]]     ;# 1) flashing window fix
   wm geometry $w +$scrh+$scrw        ;# 1) flashing window fix
   wm overrideredirect $w 1
   # Dont set window always on top! This freezes all entries so that they can't take focus anymore
   if {$ontop} {
      wm transient $w .
   }
   raise $w
   focus $w
   return $w
}
#-----------------------------------
User Comments: fvogel added on 2016-11-05 14:46:54:

In proc Show, adding

focus -force .
to the -command callback for the .tooltip.close button makes this work as expected:
   pack [ttk::button .tooltip.close -text "Close" -command "destroy .tooltip ; focus -force ." -text close]

And this, without removing neither the overrideredirect nor the transient instructions (suggestions around these were discussed in the comp.lang.tcl thread, and rejected by the OP).

I don't think this is a bug, just another case in which Windows works in a different manner than other platforms. Ticket closure suggested.


fvogel added on 2016-04-19 18:38:21:

This ticket originated in the newsgroup. There are additional info in the comp.lang.tcl discussion.