Idealism is what precedes experience; cynicism is what follows...

Friday, June 20, 2008

Adobe Flex : There is a bug in the Adobe Flex Framework ToolTipManager Implementation

I have registered it with the Adobe Flex Team.
https://bugs.adobe.com/jira/browse/SDK-15863


When using a CustomToolTip set via the ToolTipmanager.toolTipClass property, "text" is never invoked.
Its easily solved however, it just requires you to override commitProperties and set the text yourself.

  override protected function commitProperties():void
{
super.commitProperties();
text = ToolTipManager.currentTarget[ "toolTip" ];
}


And here is a complete implementation of a custom tooltip.

package
{
import mx.containers.Canvas;
import mx.controls.Button;
import mx.core.IToolTip;
import mx.managers.ToolTipManager;

public class CustomToolTip extends Canvas implements IToolTip
{
private var _button:Button;

public function CustomToolTip()
{
super();
}

override protected function createChildren():void
{
super.createChildren();
_button = new Button();
addChild( _button );
}

override protected function commitProperties():void
{
super.commitProperties();
text = ToolTipManager.currentTarget[ "toolTip" ];
}

public function get text() : String
{
return _button.label;
}
public function set text( value:String ) : void
{
_button.label = value;
}
}
}


I suppose you can also workaround it by changing the ToolTipManagerImpl class, but I prefer not to change the framework sourcecode for so many reasons that its beyond the scope of this post.

Also, I really dislike every sample out there illustrating how to implement custom tooltips, as they all involve calling a method on a toolTip event and hence requires you to use your custom ToolTip logic everywhere in your system instead of using the framework.

1 comment:

Dave said...

This bug is frustrating because it is a single-character error in ToolTipManagerImpl.as:

809: mx_internal function initializeTip():void
810: {
811: // Set the text of the tooltip.
812: if (currentToolTip is ToolTip)
813: ToolTip(currentToolTip).text = currentText;

line 812 should read:

if (currentToolTip is IToolTip)

And this would not be a problem. :-P

Dave

Blog Archive

My Network