# An issue regarding the use of CopyToClipboard with dynamic content

ColorSlider[
Dynamic[x], ImageSize -> {800, 100}, AppearanceElements -> "Spectrum"
]

Button["get color",
MessageDialog @ Dynamic[x];
CopyToClipboard @ funct @ Dynamic[x];
]

Graphics[{Dynamic[x], Disk[]}, Frame -> True, FrameLabel -> Dynamic[x]]


To get the value of RGBColor in a string form, I have changed, in turn, the above funct with OutputForm, StringForm etc. obtaining always one of two results:

Dynamic[x] (* or *)

StandardForm  \!$$\*DynamicBox[ToBoxes[Globalx, StandardForm], ImageSizeCache->{380., {2., 8.}}]$$


To track the issue I tried

 Slider[Dynamic[z]]

Print @ Dynamic[z];

Button["copy",
MessageDialog @ Dynamic[z];
CopyToClipboard  @ Dynamic[z];
]

Button["paste",
Paste  @ Dynamic @ z;
]


and understood that CopyToClipboard get the whole DynamicBox, not its 'current content'. How can I get rid of the "wrapper" ?

I just have realized taht the color value can be read by means of

InputField[Dynamic[x]]


but it's evidently an expedient and doesn' enlighten the broader subject.

• So drop the Dynamic from the button. Dynamic is HoldAll so it stays this way untill it's displayed. Button is HoldRest so you will get the current value of x anyway. p.s. you can use Setting too. – Kuba Feb 24 '16 at 21:59
• closely related: How to extract the numerical value of a dynamical variable – Kuba Feb 24 '16 at 22:01
• Thanks for your reply ! Setting does perfectly the job. I'm going to study the other topics you mentioned. – mitochondrial Feb 24 '16 at 22:09

I haven't found better duplicate so here's what you need to know:

Moreover, in your case Dynamic[x] takes the tour: Button -> Clipboard -> final destination. If you final destination is e.g. a MMA notebook, then the FrontEnd can handle this and will show you colored rectangle.
However, if you copy to let's say Notepad, you will get Dynamic[x], with no info about x because Dynamic is HoldAll.
As I've mentioned the workaround is to use Setting @ Dynamic @ x [1] or just x, the Button is HoldRest so you will copy the current value of x.
• Thanks for the reply! I'm studying the sources you pointed at. Now I undestend the behaviour of this code: Row @ {Slider[Dynamic[x]], Dynamic[x], Button["raw", Dynamic[x] >>> "deleteme.txt"], Button["value", Setting @ Dynamic[x] >>> "deleteme.txt"] }` – mitochondrial Feb 25 '16 at 16:19