14 Replies Latest reply on Jun 28, 2011 12:10 PM by wraevn

    ToolTips missing text (sometimes)

    wraevn Level 1

      I've got a Flex 3 (using 3.2 SDK - required) project that uses 3 external library projects, including some monkey-patched classes. This project also uses modules. We're using the resourceManager to retrieve all strings dynamically for the entire application (only 1 language now, but planning ahead for more).

       

      We've had an issue on and off again where the tooltips for the entire application won't work when you launch, then will work the next time you launch. By not working, I mean you see the tooltip pop up, but it has no text. This is the same for dataTips on charts and dataGrids, toolTips for buttons etc..

       

      At one point we thought it was a module problem (as it began only after we converted the project to modules) and we thought we had it fixed by using "this.moduleFactory = Application.application.systemManager;" in the creationComplete of each of the modules.

       

      Today we started seeing this issue again. Has anybody else seen anything like this? If I had to guess, I'd say it had something to do w/ classes getting loaded on time sometimes, and not other times, but I've no idea how to test this hypothesis let alone how to fix the problem.

       

      I could really use some help here!

       

      Thanks,

       

      B

        • 1. Re: ToolTips missing text (sometimes)
          Flex harUI Adobe Employee

          I would not mess around with moduleFactory assignments, especially if you

          are embedding fonts.  And if you are embedding fonts, see the post on

          embedded fonts on my blog.

           

           

          --

          Alex Harui

          Flex SDK Team

          Adobe System, Inc.

          http://blogs.adobe.com/aharui

          • 2. Re: ToolTips missing text (sometimes)
            wraevn Level 1

            Based on your thoughts that it's probably an embedded font issue (our embedded font is in a font swf) I tried a couple of things:

             

            I tried doing a manual measure of the textField inside of an extended toolTip (using a copy of the measure method from UITextFormat). But, instead of

             

            var fontModuleFactory:IFlexModuleFactory = embeddedFontRegistry.getAssociatedModuleFactory( getEmbeddedFont(font, bold, italic), moduleFactory);

             

            I said:

             

            var fontModuleFactory:IFlexModuleFactory = systemManager;

             

            which is the fallback in case the first one returned null anyway (which it wasn't). What happened was very interesting - the tooltips all sized correctly finally - but there wasn't any text in them! So - you're right - it's a font issue.

             

            I read your post here http://blogs.adobe.com/aharui/2010/03/flex_and_embedded_fonts.html many times, but a) it seems mostly Flex 4 related b) none of those properties like swfContext or getFontContext are available to my UIComponents (probably an SDK issue) c) I couldn't figure out what I'm supposed to do w/ ISWFContext or ContextualClassFactory. Is there something I can do for the entire application? Each Module? or does it have to be on a component-by-component basis?

            • 3. Re: ToolTips missing text (sometimes)
              Flex harUI Adobe Employee

              Flex 4 introduces CFF fonts, but other than that, the principle of getting

              moduleFactory to be correct still applies to older SDK versions.

               

              I think there is a TOOLTIP_HIDE event.  I would listen for it and dump out

              some information about the tooltip:   moduleFactory, fontFamily, fontWeight,

              fontStyle and maybe drill into the TextField that's supposed to show the

              text and get its embedFonts property.

              • 4. Re: ToolTips missing text (sometimes)
                cosmits Level 1

                Hi wraevn

                 

                I'm working on a similar structure app -  flex 3, resourceManager, Modules....

                and indeed after implementing modules, and using the phrase "this.moduleFactory = Application.application.systemManager;"

                I started loosing text in all kinds of tooltips in an inconsistence manner

                the reason I used "this.moduleFactory = Application.application.systemManager;"

                is that the modules wern't able to access fonts that the containing application could access,

                and after days of searching, this was the only thing that actually worked.

                 

                I was wondering if you manage to solve the tooltips text problem and would you care to share it

                 

                Cheers

                yariv

                • 5. Re: ToolTips missing text (sometimes)
                  Flex harUI Adobe Employee

                  Mucking with moduleFactory is probably asking for trouble.  Explain your

                  topology and we'll see if we can get fonts working without setting

                  moduleFactory.

                  • 6. Re: ToolTips missing text (sometimes)
                    cosmits Level 1

                    Dear Flex harUI

                    thank you for your responce

                    I have a flex 3 web app constructed with modules

                    fonts are embedded into an external swf vis css

                    if I don't include the following line, fonts are missing from the modules

                    currentModule.moduleFactory = this.systemManager;

                     

                    they apear fine in the loading app, but missing from the loaded module

                    either I don't get the fonts to display in the modules, or inconsistently show/ not show text in the custom error tooltips

                    I'm using ModuleManager to load the modules

                     

                    are there any other details I can provide?

                    would appreciate very much your answer

                    this issue is choking the project

                     

                    cheers

                    Yariv

                    • 7. Re: ToolTips missing text (sometimes)
                      wraevn Level 1

                      Probably not the most elegant solution - but the quickest to ship was to monkey-patch DataTip and include this.moduleFactory = Application.application.systemManager; in the constructor. That fixed all of our tooltips/datatips.

                       

                      Also, following Alex's suggestions on his blog, we instantiate itemRenderers w/  ContextualClassFactory ... e.g.

                       

                      alertNameCol.itemRenderer = new ContextualClassFactory ( ReadableItemRenderer, Application.application.systemManager );

                       

                      And, when including TextFields, UITextFields etc. in our custom components, we changed from var foo:TextField = new TextField() to var foo:TextField = createInFontContext( TextField ) as TextField - that fixed a bunch of font problems as well.

                      • 8. Re: ToolTips missing text (sometimes)
                        Flex harUI Adobe Employee

                        How are you instantiating the module classes?  Are you using

                        factory.create() or something else?

                        • 9. Re: ToolTips missing text (sometimes)
                          cosmits Level 1

                          Hi and thanks again for replying

                          this help is really needed!

                           

                          I am using ModuleManager: 

                          var info:IModuleInfo =   ModuleManager.getModule(someModule.swf); 

                          info.addEventListener(ModuleEvent.READY, onModuleReady);

                           

                          then using the ModuleEvent object on the event handler function like so:   

                          event.module.factory.create();

                           

                          does that help?

                          thanks again

                          Yariv

                          • 10. Re: ToolTips missing text (sometimes)
                            cosmits Level 1

                            Hi wraevn and thank you for replying

                             

                            what do you mean by

                            the quickest to ship was to monkey-patch DataTip and include this.moduleFactory = Application.application.systemManager; in the constructor. That fixed all of our tooltips/datatips.

                            the constructor of the app loading the modules?

                            the constructor of the module?

                            did you subclass Tooltip / DataTip and used this line in the subclass constructor?

                             

                            thanks again

                            Yariv

                            • 11. Re: ToolTips missing text (sometimes)
                              cosmits Level 1

                              ok, i think problem is solved for now

                              for every custom error tooltip i create i write

                              _tooltip.moduleFactory = Application.application.systemManager;

                               

                              still left with the following questions:

                              what is the internal problem that causes this bug?

                              why does this line fix it?

                              what are the drawbacks for using this "patch"?

                              why is it considered a work-around rather then a solution?

                              what is the solution then?

                               

                              the important thing is that it works for now

                              would help to answer those question to trust the application to last...

                               

                              thanks again for your help

                              Yariv

                              • 12. Re: ToolTips missing text (sometimes)
                                Flex harUI Adobe Employee

                                We would need a test case to determine the root problem.

                                • 13. Re: ToolTips missing text (sometimes)
                                  cosmits Level 1

                                  you mean an online link or the entire application source? (it is a big one...)

                                  I did a small scale test and everything went well, I wasn't able to replicate the scenario

                                  but in the real application, the steps I mentioned were the only thing that made it work...

                                  so I take it that normally this bug shouldn't occure? therefore there is no "proper" solution for it?

                                  why "messing" with the moduleFactory is not advised?

                                  cheers

                                  Yariv

                                  • 14. Re: ToolTips missing text (sometimes)
                                    wraevn Level 1

                                    we didn't sublcass - we monkey-patched DataTip. Monkey-patching is a last-resort way to a) gain access to private vars and methods b) make a global change throughout the framework.

                                     

                                    Basically - you make a complete copy of the class you wish to extend (in this case DataTip). Then you place that new class in the exact same path in your local src directory (e.g. mx.charts.chartClasses.DataTip) so it matches exactly the real Flex path. Then you make whatever changes you want. When you or any other part of the codebase calls up that class, it'll load your monkey-patched class first.

                                     

                                    Then we put the moduleFactory = code inside the DataTip constructor in the monkey-patched class.