Please, consider the following code:

  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[Global`x, StandardForm],
 ImageSizeCache->{380., {2., 8.}}]\)

To track the issue I tried


 Print @ Dynamic[z];

     MessageDialog @ Dynamic[z];
     CopyToClipboard  @ Dynamic[z];

     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


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

  • 1
    $\begingroup$ 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. $\endgroup$
    – Kuba
    Feb 24, 2016 at 21:59
  • 2
    $\begingroup$ closely related: How to extract the numerical value of a dynamical variable $\endgroup$
    – Kuba
    Feb 24, 2016 at 22:01
  • $\begingroup$ Thanks for your reply ! Setting does perfectly the job. I'm going to study the other topics you mentioned. $\endgroup$ Feb 24, 2016 at 22:09

1 Answer 1


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

from Mr. Wizard's answer to Question about MapThread and Dynamic.

In short, Dynamic doesn't do anything until it is actually displayed on screen. Therefore, you are essentially doing this (note the String):

See also the linked topic.

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.

[1]: How to extract the numerical value of a dynamical variable

  • $\begingroup$ 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"] } $\endgroup$ Feb 25, 2016 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.