I use the below commands to copy string "ABC" to clipboard.
[file: aa.tcl]
set myVar Hello
clipboard clear
clipboard append $myVar
clipboard get
Hello
It works well in the tool. But it doesn't work when I try to paste it into terminal sciprt.txt with mousewhell-click
How can I paste the variable in tcl into terminal-text file?
not working, xclip, bind, event etc ...
The clipboard
command works on the CLIPBOARD selection. This selection is usually taken when pasting the "Windows way": Using Ctrl-V or via the Paste option from the Edit menu or a context menu.
When pasting with the middle mouse button, the PRIMARY selection is taken instead. You have to use the selection
command to work with the PRIMARY selection. Unfortunately, this is a bit more cumbersome than the clipboard
command.
proc selproc {str offset count} {
return [string range $str $offset [expr {$offset + $count - 1}]]
}
set myVar Hello
selection handle . [list selproc $myVar]
selection own .