Binding a tooltip to a property that may be empty

Hello,

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?

Thanks,
Marc.

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 Node.data.description is an empty string.

Works great, thanks!