8 Replies Latest reply on Oct 15, 2013 1:47 PM by DarkLightShineth

    TextEvent.LINK only firing after focus

    SpecialK Level 1

      I am having an issue with <mx:Text> and TextEvent.LINK events. It seems that the event will fire only after the element has received focus, meaning it takes two clicks for the event to fire. The exact same code with a <mx:TextArea> works with just a single click. Is there some way around this? It is a terrible experience for the user to have to click on a link twice before it will register.

       

      Thanks in advance

        • 1. Re: TextEvent.LINK only firing after focus
          Flex harUI Adobe Employee

          What happens if you use a textArea with editable=false?

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: TextEvent.LINK only firing after focus
            SpecialK Level 1

            editable = false is how I have been using it. Let me give a little bit more background about my use case scenario. I am building a custom itemRender that extends UIComponent. My itemRender has several children, most notably two <mx:Text> components for title and body (this is a Twitter like feed application). I set title.htmlText and body.htmlText to html I receive from a REST endpoint.

             

            When I use <mx:Text>, if I focus away from the app (I should probably mention this is an AIR app), and then focus back on the app by clicking on a link embeded in either the title or body children, nothing happens. If I click again after the window has received focus, the app navigates my browser to the correct url.

             

            However, if I switch to using <mx:TextArea>, when I focus away from the app and then focus back by clicking on a  link embeded in the htmlText, I am immediately navigated to the url in my browser, which is the correct behavior.

             

            I have also experienced this faulty behavior when using a <mx:Label> as well as a native TextField. I cannot find what would make the TextArea special as it too uses an internal native TextField.

            • 3. Re: TextEvent.LINK only firing after focus
              Flex harUI Adobe Employee

              It might be a conflict with the way Flex manages focus.  Feel free to file a bug.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 4. Re: TextEvent.LINK only firing after focus
                SpecialK Level 1

                I will do that. In the meantime, here is a really simple example that demonstrates what I am talking about.

                 

                <?xml version="1.0" encoding="utf-8"?>
                <mx:WindowedApplication
                    xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="vertical">
                   
                    <mx:Script>
                        <![CDATA[
                            import mx.collections.ArrayCollection;
                           
                            [Bindable]
                            private var _data:ArrayCollection = new ArrayCollection([
                                '<a href="http://www.adobe.com">Test Link</a>',
                                '<a href="http://www.adobe.com">Test Link</a>',
                                '<a href="http://www.adobe.com">Test Link</a>',
                                '<a href="http://www.adobe.com">Test Link</a>'
                            ]);
                               
                        ]]>
                    </mx:Script>
                   
                    <mx:List dataProvider="{_data}" width="100%" selectable="false">
                        <mx:itemRenderer>
                            <mx:Component>
                                <mx:Text htmlText="{data}" />
                            </mx:Component>
                        </mx:itemRenderer>
                    </mx:List>
                   
                    <mx:List dataProvider="{_data}" width="100%" selectable="false">
                        <mx:itemRenderer>
                            <mx:Component>
                                <mx:TextArea htmlText="{data}" editable="false" />
                            </mx:Component>
                        </mx:itemRenderer>
                    </mx:List>
                   
                </mx:WindowedApplication>

                 

                If you cause the application to lose focus, but keep it in view, and then click on one of the links to give the application focus again, the <mx:Text> will not fire unless you click it again while the <mx:TextArea> will fire immediately

                 

                The naive solution in this case it to set focusEnabled = false on the List, which rectifies the problem. However, on my more complex itemRender, the issue still remains.

                • 6. Re: TextEvent.LINK only firing after focus
                  Flex harUI Adobe Employee

                  I'm sorry, I don't have bandwidth to try to research this problem at this time.  Please file the bug so we don't lose track of it.

                   

                  Alex Harui

                  Flex SDK Developer

                  Adobe Systems Inc.

                  Blog: http://blogs.adobe.com/aharui

                  • 7. Re: TextEvent.LINK only firing after focus
                    xchg.ca Level 1

                    And here is 2011, June, and this bug stll here even with Latest 4.5.1!

                    • 8. Re: TextEvent.LINK only firing after focus
                      DarkLightShineth

                      public class Text extends mx.controls.Text implements IFocusManagerComponent

                      {

                       

                          public function Text()

                          {

                          }

                       

                          //fix for https://issues.apache.org/jira/browse/FLEX-19959

                          override public function setFocus():void

                          {

                              textField.setFocus();

                          }

                      }