I'm displaying a list of buttons, some of which might be disabled. I need to show a tooltip on the disabled buttons with an explanation of why it's disabled, but it seems I can't disable the button without disabling the tooltip. Is there a simple way around this?
A:
You will need to use the ToolTipManager
class to create and destroy the tool tips manually.
This article should give you all the info you need to accomplish this:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf60d65-7ff6.html
Sly_cardinal
2010-05-27 07:43:27
I considered using ToolTipManager in my solution but this was difficult because the spark button does not dispatch mouse events when it is disabled, so I would have to use another way of detecting when the user is over the button.The simplest solution I found was to simply create extra invisible buttons on top of the disabled buttons and use their built in tooltip behaviour. Not ideal, I know.
geo
2010-05-28 11:06:59
You are correct, the Spark Button does not raise mouse events when disabled, despite explicitly stating that it does in the documentation. Are you able to use a Halo Button as an alternative? (unless you are doing some funky skinning I guess) I have raised a bug report with Adobe about the Spark Button's documentation.
Sly_cardinal
2010-05-29 15:01:34
A:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.managers.ToolTipManager;
import mx.controls.ToolTip;
private var tooltip:ToolTip;
private var p:Point;
private function whyDisable():void
{
//calculate the button position , so that roll over shows the tooltip
p=new Point();
p=localToGlobal(new Point(btn.x,btn.y));
if(btn.enabled==false)
tooltip = ToolTipManager.createToolTip('Button is disabled',p.x+(btn.width/2),p.y-20,'errorTipAbove') as ToolTip;
else
tooltip=ToolTipManager.createToolTip('Button is enabled',p.x+(btn.width/2),p.y-20,'errorTipAbove') as ToolTip;
}
]]>
</mx:Script>
<mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle">
<mx:Button id="btn" label="Show Tooltip" buttonDown="trace('ankur')" autoRepeat="true" enabled="true" rollOver="whyDisable();" rollOut="{ToolTipManager.destroyToolTip(tooltip);}"/>
</mx:VBox>
</mx:Application>
Hi, this application works on the disabled button,I used ToolTipManager to do this,
i hope this works for you
have a gr8 time
Ankur Sharma
Ankur Sharma
2010-05-28 09:21:50
thanks for the example, unfortunately I am using the spark.components.Button class, which sets mouseEnabled and mouseChildren to false when enabled is set to false. This means I cannot use rollover events.
geo
2010-05-28 10:55:15