www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to put an arbitrary string to clipboard in D?

reply tastyminerals <tastyminerals gmail.com> writes:
I made a GUI app using tkd library. I am reading the string from 
one of the app widgets and would like to put it into the 
clipboard. Does anyone have an idea how to copy a string to the 
clipboard in D?
Jul 30 2021
parent reply rikki cattermole <rikki cattermole.co.nz> writes:
On 31/07/2021 7:33 AM, tastyminerals wrote:
 I made a GUI app using tkd library. I am reading the string from one of 
 the app widgets and would like to put it into the clipboard. Does anyone 
 have an idea how to copy a string to the clipboard in D?
copyText on a Text widget appears to do what you want. https://github.com/nomad-software/tkd/blob/9ca40d117649bb9a9db108d8f92e92870b9dc77e/source/tkd/widget/text.d#L477 https://wiki.tcl-lang.org/page/tk_textCopy
Jul 30 2021
parent reply tastyminerals <tastyminerals gmail.com> writes:
On Friday, 30 July 2021 at 20:01:09 UTC, rikki cattermole wrote:
 On 31/07/2021 7:33 AM, tastyminerals wrote:
 I made a GUI app using tkd library. I am reading the string 
 from one of the app widgets and would like to put it into the 
 clipboard. Does anyone have an idea how to copy a string to 
 the clipboard in D?
copyText on a Text widget appears to do what you want. https://github.com/nomad-software/tkd/blob/9ca40d117649bb9a9db108d8f92e92870b9dc77e/source/tkd/widget/text.d#L477 https://wiki.tcl-lang.org/page/tk_textCopy
The problem is that I don't use Text widget but retrieve the string from TreeView widget which only has getSelectedRows method. So I thought there may be a way in D to communicate with the system clipboard...
Jul 31 2021
next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
On 01/08/2021 6:30 AM, tastyminerals wrote:
 So I thought there may be a way in D to communicate with the system 
 clipboard...
No, this requires a windowing library and yes a window to do it (depending on the windowing system and even the desktop environment).
Jul 31 2021
prev sibling parent Adam D Ruppe <destructionator gmail.com> writes:
On Saturday, 31 July 2021 at 18:30:47 UTC, tastyminerals wrote:
 So I thought there may be a way in D to communicate with the 
 system clipboard...
You can always call the same system functions from D that you'd use from C. This is the source to my simpledisplay.d library on its clipboard function: https://github.com/adamdruppe/arsd/blob/master/simpledisplay.d#L5279 The Windows side isn't too bad, the linux side a bit more complicated. Generally window libs offer something for this but idk about the one you're using.
Jul 31 2021