How to suppress Tooltip in built-in templates?

Quick fixes for specific cases

TemplateBox has Tooltip option so we can use it. There are three ways I'm aware of:

  • go to Core.nb stylesheet, find "Binomial" style and add Tooltip->None to its TemplateBoxOptions.

  • or you can target specific expression, the problem is that you have to be precise because TemplateBoxOptions will be overwritten by those from a stylesheet for a specific template How to work with BoxOptions

    Here is the way to go in some cases:

    ToBoxes[
     TraditionalForm @ Binomial["a", "b"]
    ] /.  t : TemplateBox[_, "Binomial", ___] :> Append[t, Tooltip -> None] // RawBoxes
    
  • or polish the definition

    Unprotect @ Binomial;
    
    Binomial /: MakeBoxes[ Binomial[a_, b_], fmt : TraditionalForm] := TemplateBox[
       {MakeBoxes[a, fmt], MakeBoxes[b, fmt]}, "Binomial", Tooltip -> None];
    
    Protect @ Binomial;
    
    TraditionalForm @ Binomial["as", "b"]
    

Rough approach:

Tooltip resources are stored in

FileNameJoin[{
 $InstallationDirectory, "SystemFiles", "FrontEnd", "TextResources", "ToolTip.tr"}]

In order to not mess with installation directory you can copy this file to $UserBaseDirectory/SystemFiles... and replace labels you want. For example:

@@resource ToolTipCut

Cut (replace this line with your own label and save it.)

@|

  • This is a global replacement so this and each next session will be affected.

Not a big deal if your goal is to customize tooltips in Mathematica for user/client who want's different language.


More flexible approach but very hairy:

  • Case:

    Let's say we want to have one and only one Manipulator with changed labels.

  • Idea:

    We are changing the file during initialization and replacing it back after cell contents are displayed. We have to force FrontEnd to forget cached string resources in between those steps.

    We will use here undocumented function:

    FrontEndExecute @ FrontEnd`FlushTextResourceCaches[]
    

    to force FrontEnd to forget current resurces.


(*aux. functions,
  you need to put them in to the initialization or something similar 
  if you want them to work after reopening the notebook*)

replaceTooltip[rules_List] :=  StringReplace[ file,
    ("\n" ~~ # ~~ "\n" :> "\n" <> #2 <> "\n") & @@@ rules]

exportAndFlush[msg_] := (
  Export[  
     FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd",
         "TextResources", "ToolTip.tr"}],
   replaceTooltip[msg],
   "Text"
   ];
  FrontEndExecute @ FrontEnd`FlushTextResourceCaches[]
  )

Dynamic[
  Manipulator[Dynamic@x, Appearance -> "Open"],
  None,
  Initialization :> (
    exportAndFlush[{"Play" -> "CustomPlayLabel"}];
    SetOptions[ EvaluationCell[],  CellDynamicExpression :> 
        Refresh[exportAndFlush[{"CustomPlayLabel" -> "Play"}], None]
    ];
  )
]

enter image description here

But when we create new one it will have default label:

Manipulator[Dynamic@x, Appearance -> "Open"]

enter image description here

Keep in mind:

  • FlushTextResourceCaches[] is undocumented so maybe not stable, and not so fast. I haven't tested if one can flush resources partially, not globally.

  • This approach is basing on the assumption that CellDynamicExpression fires after Initialization. Which is not described anywhere but seems to be true from my tests.

    Why we are using this, not just evalaute flush after cell is created? Because we want this label to be preserved between sessions and if you close the notebook and open again, resources are loaded again which would overwrite our label.

  • Templates' tooltips, like Binomial, are stored in form of Rules

    @@resource TemplateBoxTooltips { Abs" -> "Abs", ...

    so you have to extend replaceTooltip function if you want to work with them.

  • code above is only to show minimal example and describe the idea. for real app you need to add additional checks about the file about pattern you use for replacement etc. etc.


In version 7 this suppresses the Show Animation Controls tooltip but fails to suppress the Play, Step Forward etc. ones.

Style[
 Manipulate[Plot[Sin[x (1 + a x)], {x, 0, 6}], {a, 0, 2}],
 TooltipBoxOptions -> {DefaultLabelStyle -> {Opacity[0], 0}}
]