12
$\begingroup$

...or maybe switch the message. But I will be happy with no Tooltip at all.

enter image description here

I've naively tried with

Block[{$PerformanceGoal="Speed"}, ...]

because it works in case of Charts` tooltips, but with no effect :)

$\endgroup$
3
  • $\begingroup$ I looked through definitions. It seems that Manipulator uses AnimatorBox or Animator (you can check it by evaluating FE`Evaluate@ FEPrivate`FrontEndResource["FEExpressions", "Manipulator04"][d2, d1, mrange, a, b, e, c, ap, ii, o, i, ape, auto, av, Dynamic[open], Dynamic[paused], Dynamic[rate], Dynamic[dir]]). Maybe it is simpler to solve this problem with Animator, but I don't know how to go deeper :) $\endgroup$
    – ybeltukov
    Jan 21, 2014 at 20:46
  • $\begingroup$ @ybeltukov That's only an example, dealing with it won't help with Binomial etc. I'm looking for sort of generic approach. Not sure it isn't out of scope, but folks here know surprising things :). Thanks for your attention. $\endgroup$
    – Kuba
    Jan 21, 2014 at 20:49
  • $\begingroup$ I tried SetOptions[.., TooltipBoxOptions -> {TooltipDelay -> Infinity}] on $FrontEndSession, EvaluationNotebook[] and as a cell option to no avail. Also tried numeric delays. Off on the wrong trail, I suppose. $\endgroup$
    – Michael E2
    Jan 22, 2014 at 0:05

2 Answers 2

5
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ From your spelunking do you understand why TooltipBoxOptions fails? Are the values hard-coded? $\endgroup$
    – Mr.Wizard
    May 21, 2015 at 8:16
  • $\begingroup$ @Mr.Wizard No, sorry :/ $\endgroup$
    – Kuba
    May 21, 2015 at 8:20
4
$\begingroup$

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}}
]
$\endgroup$
3
  • $\begingroup$ Unfortunately, in V9.0.1.0 it does not supress :/. $\endgroup$
    – Kuba
    Feb 5, 2014 at 7:45
  • $\begingroup$ @Kuba Doesn't suppress anything? Too bad. I was hoping we could find a way to inject this setting into the template or template creation somehow. $\endgroup$
    – Mr.Wizard
    Feb 5, 2014 at 10:07
  • $\begingroup$ No, Show animation controls is still there :/ $\endgroup$
    – Kuba
    Feb 5, 2014 at 10:14

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.