ActionScript 3.0, Adobe Flex

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s