I’m setting a tooltip on a label with label.tooltip = MyCustomObject(). MyCustomObject uses the canvas rendering context to format text correctly. When I set it as a tooltip, it is not added to the zCanvas instance and thus any internal calls to this.getCanvas() return null. Is there some other way to do this so that I can have access and format my text correctly.
Could you describe the workflow ? It is not clear what is “format text correctly” and when it is going on.
In general you can override “setParent(p)” method of tooltip component to be aware when it gets parent and calculate/format a text
To measure text metrics you don’t need get 2D context of zCanvas. Use “zebra.ui.Font” instead to measure text metrics. Think you should use font property of your label or text render component and call “stringWidth(s)” method to get string width in pixels.