...or maybe switch the message. But I will be happy with no Tooltip
at all.
I've naively tried with
Block[{$PerformanceGoal="Speed"}, ...]
because it works in case of Charts`
tooltips, but with no effect :)
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"]
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.)
@|
Not a big deal if your goal is to customize tooltips in Mathematica for user/client who want's different language.
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]
];
)
]
But when we create new one it will have default label:
Manipulator[Dynamic@x, Appearance -> "Open"]
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.
TooltipBoxOptions
fails? Are the values hard-coded?
$\endgroup$
Commented
May 21, 2015 at 8:16
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}}
]
Manipulator
usesAnimatorBox
orAnimator
(you can check it by evaluatingFE`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 withAnimator
, but I don't know how to go deeper :) $\endgroup$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$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$