4
$\begingroup$

I was trying to understand what happens when I insert Deployed -> True/False in an ExpressionCell but couldn't see a difference in most of the cases shown in the documentation.

First example:

ExpressionCell[{Graphics[Disk[]], Slider2D[]}, Deployed -> False]

I can't see what changes, if I change Deployed -> False to Deployed -> True. The slider can be moved in both cases.

Second example:

{Graphics[{Disk[], Inset[Slider2D[]]}], Deploy[Graphics[{Disk[], Inset[Slider2D[]]}]]}

I can't see a difference between the two Graphics objects.

Third Example:

{Panel["This text is selectable and editable"], Deploy[Panel["This text is not selectable or editable"]]}

This is the only example where I can see the difference.

$\endgroup$
1
  • $\begingroup$ Have you tried that? I've just tried it and I can still rotate the graphic. $\endgroup$
    – Merlin
    May 18, 2022 at 14:17

1 Answer 1

3
$\begingroup$

[Note: I assumed CellPrint was necessary, which was wrong. I did not realize that ExpressionCell as output becomes an InterpretationBox. See end.]

CellPrint[] on given example

For the given code, you can't edit the graphics with Deployed -> True. (Click on the graphics, then double click, then drag the disk around.) You also cannot resize the graphics or use Get Coordinates, the Drawing Tools, or other editing actions in the graphics context menu. I also cannot select any elements in the cell, although the slider responds to mouse-down and mouse-dragged events.

enter image description here

Output cells

It's a bit more complicated if you use cell styles. The default "Output" style has GraphicsBoxOptions and Graphics3DBoxOptions that override Deployed to set it to False. To counter that, you need to add one or both of the following Cell options:

GraphicsBoxOptions -> {
 DefaultBaseStyle -> {"Graphics", Deployed -> True}}

Graphics3DBoxOptions->{
 DefaultBaseStyle -> {"Graphics3D", Deployed -> True}}

If you do not do this, then the cell will be deployed but the graphics editable. When the graphics are edited, the cell is converted to an "Input" cell and the Deployed option is removed.

Thus the following gives a deployed cell (but the slider still responds to mouse events):

ExpressionCell[{Graphics[Disk[]], Slider2D[]},
  "Output", Deployed -> True, 
  GraphicsBoxOptions -> {DefaultBaseStyle -> {"Graphics", 
      Deployed -> True}}] // CellPrint

If we remove the cell option Deployed -> True, we get a regular cell with deployed graphics. However, if the cell is edited, it will be converted to an "Input" cell and un-deployed.

ExpressionCell[{Graphics[Disk[]], Slider2D[]},
  "Output",(*Deployed->True,*)
  GraphicsBoxOptions -> {DefaultBaseStyle -> {"Graphics", 
      Deployed -> True}}] // CellPrint 

Other cell styles may be investigated as desired. I do not remember this happening several years back (overriding Deployed with box options), but maybe my memory is wrong. I don't have a way to check at this point.

The given example without CellPrint[]

The raw ExpressionCell[..] results in an InterpretationBox[] in an output cell. The InterpretationBox[] is by default Editable -> False. Thus the graphics are not editable, no matter what the setting Deployed is. Below is the cell expression of the output:

ExpressionCell[{Graphics[Disk[]], Slider2D[]}, Deployed -> False]
(*
Cell[BoxData[
 InterpretationBox[Cell[BoxData[
   RowBox[{"{", 
    RowBox[{
     GraphicsBox[DiskBox[{0, 0}]], ",", 
     Slider2DBox[{0.5, 0.5}]}], "}"}]]],
  ExpressionCell[{
    Graphics[
     Disk[{0, 0}]], 
    Slider2D[]}]]], "Output",
 CellChangeTimes->..., CellLabel->...]
*)

Since the example comes from the docs for Deployed, I would say it's a bad example to show how Deployed works. Since it's the only example, it's doubly bad.

You can play with the following to get something where Deployed has an effect:

ExpressionCell[{Graphics[Disk[]], Slider2D[]},
 Deployed -> False (* True *), 
 Editable -> True]

I got it to give me the error:

INTERNAL SELF-TEST ERROR: Graphics2DEventTracker|cpp|207
$\endgroup$
7
  • $\begingroup$ I can edit the graphics, no matter if it's Deployed->True or Deployed->False. I can change the size of the black disk, open the Drawing Tools, move the slider. $\endgroup$
    – Merlin
    May 18, 2022 at 14:48
  • $\begingroup$ @Merlin I cannot edit the graphics with Deployed -> True. I can move the slider (as shown in the image). -- What system are you using (Windows, Mac, Linux, cloud/online)? $\endgroup$
    – Michael E2
    May 18, 2022 at 14:55
  • $\begingroup$ That's strange, I am using Mac. I get this orange square in your first picture for both versions of Deployed. $\endgroup$
    – Merlin
    May 18, 2022 at 15:51
  • $\begingroup$ @Merlin I updated my answer to reflect subtleties that may apply to what code you're using. See if it conforms to your experience. If not, we probably need to see the code you're executing. I had been assuming one thing, but your different results suggests my initial assumption was wrong. $\endgroup$
    – Michael E2
    May 18, 2022 at 18:15
  • $\begingroup$ Thank you very much for your effort and the detailed answer! I don't have another code, I was actually just starting with the Wolfram Documentation of "Deployed" and tried the given examples (the ones that are described in my question) and wondered how it works because I couldn't see a difference (the only exception was the text cell example - the output was not selectable and editable). $\endgroup$
    – Merlin
    May 18, 2022 at 18:36

Your Answer

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

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