Prev: help adding timeout to nntp?
Next: ISO: ideas for creating a more consistent user experience wthcopy and paste in Tk
From: Larry W. Virden on 21 Jun 2010 12:26 Platform: Tcl/Tk scripts running on a SPARC Solaris machine, displaying via X through Hummingbird Exceed onto a Microsoft Windows XP desktop. Example application sets up a simple entry widget and packs it. package require Tk entry .t pack .t User then types text into the widget, selects the text via mouse drag selection, and presses ^C to copy. User then moves mouse to either IE or Word, etc. - some Microsoft local desktop application. They press ^V to paste. The results are, in general, not pleasing. In this specific scenario, the user sees only one character - the first of the selection - appear after the paste operation. If the user double clicks to set the selection field, then copies, the text selected appears as expected. However, if a second text selection in the same entry widget is double clicked and a ^C typed, the paste only displays the originally selected text. I've tried both Tk 8.5.4 as well as Tk 8.6 beta (June 13th cvs head). The behavior remains the same. The copy and pastes in all these cases works fine if the user points to another Tk application and pastes into an appropriate widget. The problem exists only when trying to perform the paste in a non-Tk application. Unfortunately, that use case is a pretty common one. Have others seen similar behavior? What kinds of work arounds around this unexpected behavior have people found to be helpful?
From: Larry W. Virden on 21 Jun 2010 13:31 On Jun 21, 12:33 pm, drscr...(a)gmail.com wrote: > On 6/21/2010 12:26 PM, Larry W. Virden wrote: > > > The copy and pastes in all these cases works fine if the user points > > to another Tk application and pastes into an appropriate widget. > > > The problem exists only when trying to perform the paste in a non-Tk > > application. Unfortunately, that use case is a pretty common one. > > It sounds like the application does not manage the selection/clipboard > explicitly. You can redefine copy/paste procedures so that they rely on > the contents of the selection/clipboard. That way, the application > should behave the same across applications. > > DrS I was thinking along those lines. Somehow, however, the end results have to be robust enough so that copy and paste works between tk apps (including ones which we cannot modify bindings), X applications, and Windows desktop applications. Do you know of any tutorials that discuss the various issues that need to be addressed in such a thing?
From: drscrypt on 21 Jun 2010 15:21
On 6/21/2010 1:31 PM, Larry W. Virden wrote: > I was thinking along those lines. Somehow, however, the end results > have to be robust enough so that copy and paste works between tk apps > (including ones which we cannot modify bindings), X applications, and > Windows desktop applications. > > Do you know of any tutorials that discuss the various issues that need > to be addressed in such a thing? I believe Tk's own selection and clipboard commands provide access to the underlying system facilities. So, if you rely on the clipboard's contents, for example, when doing copy-paste, you should be good. The default bindings that come with Tk is generally good enough but as you discovered, sometimes what the OS thinks is in the clipboard is not the same as what Tk thinks it is. These commands are pretty straightforward and relatively simply as they only have a few subcommands. The only gotcha would be to make sure to check for the object type in the clipboard - as the OS may allow anything to be in there and not just text. I don't have any tutorials but a good place example would be sample code on wiki that does drag-and-drop. Also, the man pages for these two commands have examples. It should go something like this: Copy: clipboard clear clipboard append {my own text} Paste: clipboard get -type STRING |