Hi, Maik/Mike.

 

The ToolTipManager handles automatically creating and destroying both tool tips and validation error tips as the user mouses around, and it isn't designed to work the way you're asking. But here's one way to work around it to make "sticky" validation error tips.

 

The ideas are:

 

1. Error tips are just instances of the ToolTip class which pull their styles from the ErrorTip stylesheet.

 

2. You can create them yourself with createClassObject() when a component becomes invalid, by handling its 'invalid' event.

 

3. You can destroy them when the component becomes valid again, by handling its 'valid' event.

 

4. Since you are creating and destroying the error tips yourself, you have to defeat the ToolTipManager's attempt show them also. You can do this by handling the 'showToolTip' event and making the ToolTipManager-created error tip invisible. (A heavier-handed technique would be to set ToolTipManager.enabled = false, but that would disable all tool tips and error tips.)

 

There are a few other details to worry about:

 

5. When you use createClassObject() you must ensure that the name and depth are unique; otherwise, multiple error tips will clobber each other. I construct a unique name such as "errorTipssn" or "errorTipphone" by incorporating the id of the corresponding component. And I ensure a unique depth using a simple incrementing counter. There may be better ways to do both of these.

 

6. You have to set tabEnabled = false on the error tip so that the user can't tab to it.

 

7. You have to position the error tip next to the invalid component yourself, using move().

 

8. When you want to hide the ToolTipManager-created error tip in the 'showToolTip' handler, you have to do so by setting its alpha to 0 rather than by setting its visible property to false. The reason is that the 'showToolTip' event is dispatched just before the ToolTipManager shows the error tip by setting its visible property to true.

 

Here's a working example:

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" verticalGap="20">

 

      <mx:Script><![CDATA[

 

            import mx.controls.ToolTip;

            import mx.core.UIObject;

                       

            var errorTipCounter:Number = 0;

           

            function handleInvalidEvent(event:Object):Void

            {

                  var target:UIObject = event.target;

                  var errorTip:ToolTip = ToolTip(createClassObject(ToolTip, "errorTip" + target.id, errorTipDepth++));

                  errorTip.setStyle("styleName", "ErrorTip");

                  errorTip.text = event.target.errorString;

                  errorTip.tabEnabled = false;

                  errorTip.move(target.x + target.width, target.y);

            }

 

            function handleValidEvent(event:Object):Void

            {

                  destroyObject("errorTip" + event.target.id);

            }

     

      ]]></mx:Script>

 

      <mx:Model id="model">

            <ssn>{ssn.text}</ssn>

            <phone>{phone.text}</phone>

      </mx:Model>

     

      <mx:SocialSecurityValidator field="model.ssn"/>

      <mx:PhoneNumberValidator field="model.phone"/>

 

      <mx:TextInput id="ssn" showToolTip="event.toolTip.alpha = 0" invalid="handleInvalidEvent(event)" valid="handleValidEvent(event)"/>

      <mx:TextInput id="phone" showToolTip="event.toolTip.alpha = 0" invalid="handleInvalidEvent(event)" valid="handleValidEvent(event)"/>

     

</mx:Application>

 

- Gordon

 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of rockmoyosa
Sent: Thursday, June 23, 2005 12:14 AM
To: [email protected]
Subject: [flexcoders] Re: Errortip not only on MouseOver

 

It was only an example. What I want is the following. When validation

fails....the ErrorTip has to appear immediately,(and not on another

mouseOver Event, which sometime requires to move the mouse out and

over before before mouse over event is triggered). And when I move to

another textinput the Errortip still has to be visible. So not only

when I have a mouseOver.

 

Mike

 

--- In [email protected], "Gordon Smith" <[EMAIL PROTECTED]> wrote:

> Can you explain your use case in more detail? I'm having a hard time

> understanding why you'd want to show an ErrorTip on mouseOut. You don't

> want the error explanation to appear when the user points to the

> component with the red border, but you do want it to appear when the

> user doesn't point at it? That seems really weird. And what if multiple

> components have errors?

>

>

> - Gordon

>

>

> ________________________________

>

> From: [email protected] [mailto:[EMAIL PROTECTED] On

> Behalf Of Matt Chotin

> Sent: Wednesday, June 22, 2005 9:49 PM

> To: [email protected]

> Subject: RE: [flexcoders] Errortip not only on MouseOver

>

>

> It doesn't look like we have an easy way for you to turn it on, maybe

> Gordon knows but I couldn't find anything.

>

>

> Matt

>

>

> ________________________________

>

> From: [email protected] [mailto:[EMAIL PROTECTED] On

> Behalf Of rockmoyosa

> Sent: Wednesday, June 22, 2005 4:44 AM

> To: [email protected]

> Subject: [flexcoders] Errortip not only on MouseOver

>

>

> I know I saw this topic already but I can't find it anymore. But is

> there a way to show a ErrorTip not only on MouseOver, but for example

> on MouseOut?

>

>

> Maik

>

>

>

>

>

>

> --

> Flexcoders Mailing List

> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt

> Search Archives:

> http://www.mail-archive.com/flexcoders%40yahoogroups.com

>

>

>

>

> ________________________________

>

> Yahoo! Groups Links

>

> *   To visit your group on the web, go to:

>     http://groups.yahoo.com/group/flexcoders/

>       

> *   To unsubscribe from this group, send an email to:

>     [EMAIL PROTECTED]

> <mailto:[EMAIL PROTECTED]>

>       

> *   Your use of Yahoo! Groups is subject to the Yahoo! Terms of

> Service <http://docs.yahoo.com/info/terms/> .

 

 

 

 

--

Flexcoders Mailing List

FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt

Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com

Yahoo! Groups Links

 

<*> To visit your group on the web, go to:

    http://groups.yahoo.com/group/flexcoders/

 

<*> To unsubscribe from this group, send an email to:

    [EMAIL PROTECTED]

 

<*> Your use of Yahoo! Groups is subject to:

    http://docs.yahoo.com/info/terms/

 

 

 

 



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




Yahoo! Groups Links

Reply via email to