Raghu
Raghu

Reputation: 45

flex htmlText in tooltip created by TooltipManager

I need to show htmlText in custom tooltip created by TooltipManager.

Below is the code.

myToolTip = ToolTipManager.createToolTip(text, pt.x, pt.y, "errorTipAbove") as ToolTip; myToolTip.setStyle("borderColor", "#FAF8CC"); myToolTip.setStyle("color", "black"); myToolTip.setStyle("fontSize","9");

I have tried the following thing.

http://flexscript.wordpress.com/2008/08/19/flex-html-tooltip-component/

But that works if we set htmlText to a tooltip eg: button.

Please help.

Upvotes: 0

Views: 3148

Answers (1)

2DH
2DH

Reputation: 1638

Just look inside the code of ToolTipManagerImpl and you'll get your answer. Here's how createToolTip function creates toolTip:

public function createToolTip(text:String, x:Number, y:Number,
    errorTipBorderStyle:String = null, context:IUIComponent = null):IToolTip{

    var toolTip:ToolTip = new ToolTip();

    var sm:ISystemManager = context ? context.systemManager as ISystemManager:
        ApplicationGlobals.application.systemManager as ISystemManager;
    sm.topLevelSystemManager.addChildToSandboxRoot(
        "toolTipChildren", toolTip as DisplayObject);

    if (errorTipBorderStyle){
        toolTip.setStyle("styleName", "errorTip");
        toolTip.setStyle("borderStyle", errorTipBorderStyle);
    }

    toolTip.text = text;

    sizeTip(toolTip);

    toolTip.move(x, y);
    // Ensure that tip is on screen?
    // Should x and y for error tip be tip of pointy border?

    // show effect?

    return toolTip as IToolTip;
}

So your answer is:

Create your own utility class with your own implementation of createToolTip function. Copy all the code from Adobe's implementation and change

 var toolTip:ToolTip = new ToolTip(); -> var toolTip:ToolTip = new HTMLToolTip();

using component from the page you mentioned.

PS: You need to copy sizeTip function as well.

Upvotes: 1

Related Questions