tags:

views:

34

answers:

2

hi,

is "Tooltip" an option if I want a caption with buttons ?

I actually need to add a fading-in caption on top of my object without changing its width. (I guess not adding directly the faded-in caption to the MXML component.

I was wondering if Tooltip can be used for this. Is possible to click on it ? And add custom components to it ?

thanks

A: 

It's not possible to click on a tooltip. If you need to pop up some other kind of container that the user can interact with, you should use the PopupManager.

Robusto
thanks for reply. Can I add and remove a popup on roll over/out ? Or is too much computation ? For example I have 30 components in a row and each of them has its own popup. When I move the mouse over them, the related pop-up should become visible and disappear.
Patrick
Furthermore, if I move the mouse out from the component and over the popup, it should remain visible. thanks
Patrick
Yes, you just add the appropriate event listener and call the close() method in the handler.
Robusto
How can I do it more precisely ? I was considering to use a Timer on mouse out event, and add an "if mouse is not on popup window" then you can close it.
Patrick
You are talking about a hybrid item here, saying you want to click on it but you want it to act like a tooltip. At some point you have to make up your mind. If you want the fade-out on mouseout, then use your timer. Otherwise, better to add a click handler to the SystemManager so that anywhere else the user clicks, the popup closes. Also have an "X" button in the top right corner that affirmatively closes the popup.
Robusto
No, I didn't explain myself very well: I *always* want the popup to disappear if I roll out the mouse from my item. There is only 1 case in which I don't want it to disappear: when the mouse is over the popup itself. Because I'm going to add buttons in it, so I want the user able to interact with it. I hope now it is clear.
Patrick
So start the timer on mouseout from your trigger component, cancel it on mouseover in your popup, and call the close method affirmatively on mouseout from your popup.
Robusto
I solved differently adding this if condition to both popup window and item itself (without using Timers): if (!caption.hitTestPoint(stage.mouseX,stage.mouseY,true)) { PopUpManager.removePopUp(caption); }
Patrick
That works too.
Robusto
+1  A: 

No tooltip is not an option. Its used to display some caption.

//dataTipFunction

public function dtFunc(hd:HitData):String {
        return hd.item;
}

Now you can show the custom caption on what you want to display, if you want a clickable thing on your caption. You need to create a component and over ride updateDisplayList Method

 override protected function
        updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void {
}

This method will make sure how your component is like, then you need to play with the invalidateDisplayList(); and other methods on when re drawing your components what your components behavior should be.

Vinothbabu
Sorry could you elaborate more ? For "redrawing my component" you mean adding/removing children to it ? Then i could you states in MXML, rather than actionscript code to add or remove them ? But my main concern is to keep the same initial width of the component even if I add a caption into it. Is this possible ? Otherwise I need to add the caption outside of it
Patrick
I think you restrict your caption length by splitting it. This will make sure you don't need to worry about the width of the component which will not expand. I have replied to your other post on this connection.
Vinothbabu