3
$\begingroup$

(Cross-posted on the Wolfram Community.)

When we select an Image in the FrontEnd, the Image Assistant Toolbar appears attached under it:

toolbar

How can we temporarily prevent the toolbar from appearing when an Image is selected?

$\endgroup$

3 Answers 3

3
$\begingroup$

Searching through the options we find ImageEditMode, which appears to do the trick:

Checkbox@Dynamic@enabled
Style[RandomImage[], RasterBoxOptions -> {ImageEditMode -> Dynamic@enabled}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks. But unfortunately this disables the zooming tooltip functionality that I want to keep working... :( My goal is to disable only the toolbar, not the tooltip functionality. $\endgroup$ Sep 18, 2022 at 14:31
  • $\begingroup$ Sorry, I should have been more explicit in my answer... I noticed that too, that's why I made the example with a Dynamic option value. You can set the value to True before invoking the tooltip, and back to False when you are done. Would that solve your problems? $\endgroup$
    – Lukas Lang
    Sep 18, 2022 at 15:52
  • $\begingroup$ Not really. Because I'm assuming iterative creation of markers, and therefore it would be convenient to have the tooltip functionality available throughout the session. The toolbar simply takes up too much screen space and gets in the way. $\endgroup$ Sep 18, 2022 at 16:04
3
$\begingroup$

An alternative would be the following stylesheet-based approach:

(* add this to the Stylesheet of the notebook / the StyleDefinitions option *)
Cell[StyleData["AttachedCell"],
  CellSize->Dynamic@If[
    Not[CurrentValue[$FrontEndSession,{TaggingRules,"ImageAssistantEnabled"}]] && 
     CurrentValue[CellTags]==="AttachedImage2D",
    {0,0},
    {Automatic,Automatic}
  ]
]

(* this goes into the notebook itself *)
Checkbox@Dynamic@CurrentValue[$FrontEndSession, {TaggingRules, "ImageAssistantEnabled"}]
RandomImage[]

CurrentValue[$FrontEnd, "DisplayImagePixels"] = "DetailExploreView";
SelectionMove[PreviousCell[], All, CellContents]
FrontEndExecute[FrontEnd`Select2DTool["GetPixelPointMarkers"]]

enter image description here

Notes:

  • Effectively, this modifies the style of all attached cells (of which the toolbar is one) and sets their CellSize to {0,0} if we have an enable-flag set and the cell has the "AttachedImage2D" CellTags entry.

  • This method shouldn't interfere with any related functionality, since the toolbar is still "there", just not visible to the user.

  • The flag is set as a $FrontEndSession TaggingRules entry since I couldn't get global variables to work in my quick tests, and that seemed like the next best thing.

  • As for the tag: I discovered that by looking at the code of the toolbar, and noting that the outermost cell had this tag as identifying information (I would have preferred a named style, but this is close enough):

    FileNameJoin@{$InstallationDirectory, "SystemFiles", "FrontEnd", "SystemResources", "AttachedImage2D.nb"}
    
$\endgroup$
2
  • $\begingroup$ May be it is possible to use CellDynamicExpression for this instead of StyleDefinitions? Like this (but this naive implementation doesn't work): CellDynamicExpression -> Dynamic[CurrentValue[ First@Cells[EvaluationCell[], CellTags -> "AttachedImage2D", AttachedCell -> True], CellSize], (# = {0, 0}) &]? $\endgroup$ Sep 19, 2022 at 6:24
  • $\begingroup$ @AlexeyPopkov You'd probably need to force continuous updating using UpdateInternal, which seems like it could kill performance $\endgroup$
    – Lukas Lang
    Sep 19, 2022 at 8:24
1
$\begingroup$

For now, I know only how to remove the toolbar programmatically:

NotebookDelete[Cells[CellTags -> "AttachedImage2D", AttachedCell -> True]]

But it appears again when I click on the image...

$\endgroup$

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.