Binding a tooltip to a property that may be empty


I have the tooltip on a node defined as follows:

toolTip: $go(go.Adornment, “Auto”,
$go(go.Shape, { fill: “#CCFFCC” }),
$go(go.TextBlock, { margin: 4 }, new go.Binding(“text”, “description”)))

The thing is, the property “description” may sometimes be an empty string, and in such a case I would want to avoid showing the tooltip (it shows up as a green rectangle in this example).

How would I do that?


Well, one solution is to make the Shape not visible when the text is empty:
$go(go.Shape, …, new go.Binding(“visible”, “description”, function(d) { return d !== “”; }))
But you might think this is a bit inelegant.

More generally you could override the ToolManager.showTooltip method to be a no-op when the is an empty string.

Works great, thanks!