1 2 Previous Next 48 Replies Latest reply: Dec 19, 2012 3:02 AM by Cenchen Go to original post RSS
      • 40. Re: [JS] Menu Added via Scripting Moves
        Harbs. CommunityMVP

        John Hawkinson wrote:

        The problem is that it is often fairly subtle "when you really need it," and you don't notice until you've been bitten by it.

        Everyone is pretty much always better off with ===.

         

        I actually came across a situation where === was problematic, but I don't remember the details. There's no replacement for properly learning a language you use. (Whether it's a spoken language or computer one...)

         

         

        John Hawkinson wrote:

         

        Crockford.

         

        Oops. Never nice to bollix up someone's name...

        • 41. Re: [JS] Menu Added via Scripting Moves
          John Hawkinson CommunityMVP

          I actually came across a situation where === was problematic, but I don't remember the details.

          I think a common case is confusion between null and undefined. For instance:

           

          var v;

          ...

          if (v==0) { v="now initialized!"; }

           

          will "work" and initialize v, because v is undefined, and "undefined==0" returns true. So if you just changed it to

           

          var v;

          ...

          if (v===0) { v="now initialized"; }

           

          then v would never get initialized. Of course, this is bad code because you should have initialized v in the var line anyhow, or you should have tested it against "undefined" and not "0" or "null," or halfadozen other reasons.

           

          Anyhow, I feel like your exception proves the rule. Use '===' always, unless you learn the language well enough to require truthiness promotion, because if you don't, you are likely to make an assumption about whether something is false versus null versus undefined, and that assumption will come back and hurt you later.

          • 42. Re: [JS] Menu Added via Scripting Moves
            Harbs. CommunityMVP

            No. That wasn't what I was talking about. I think it had something to do with String objects and String literals. But, I don't remember...

             

            Harbs

            • 43. Re: [JS] Menu Added via Scripting Moves
              Harbs. CommunityMVP

              John Hawkinson wrote:

               

              Anyhow, I feel like your exception proves the rule. Use '===' always, unless you learn the language well enough to require truthiness promotion, because if you don't, you are likely to make an assumption about whether something is false versus null versus undefined, and that assumption will come back and hurt you later.

              This is a bit like philosophy. You can argue both sides until you're blue in the face. Just about anyone coming from a C background would probably disagree. There's quite a lot of people who look at 0 and false as synonymous...

               

              Whatever; I have bigger fish to fry...

               

              Harbs

              • 44. Re: [JS] Menu Added via Scripting Moves
                JuMayr

                Hi Marc,

                 

                i tried your MenuLoader and it works like a charm.

                One question is still open: Is there a chance to create KeyboardShortcuts for a custom menu that will work even after a ShutDown & Restart of InDesign?

                 

                Cheers

                Juergen

                • 45. Re: [JS] Menu Added via Scripting Moves
                  John Hawkinson CommunityMVP

                  Juergen:

                  One question is still open: Is there a chance to create KeyboardShortcuts for a custom menu that will work even after a ShutDown & Restart of InDesign?

                  They should just work. Did you try them?

                   

                  Please note that you cannot create KBSCs in the scripting interface, you must do so by hand in the UI. (well, I suppose you could edit InDesign's xml file that stores this information, but that wouldn't be very...clean.)

                  • 46. Re: [JS] Menu Added via Scripting Moves
                    JuMayr Community Member

                    Hi John,

                     

                    i created the KBSCs via the Indesign UI.

                    They are shown in the menu and work.

                    But when i restart Indesign they are gone.

                     

                    Cheers

                    Juergen

                    • 47. Re: [JS] Menu Added via Scripting Moves
                      Marc Autret MeganK

                      JuMayr wrote:

                       

                      Hi Marc,

                       

                      i tried your MenuLoader and it works like a charm.

                      One question is still open: Is there a chance to create KeyboardShortcuts for a custom menu that will work even after a ShutDown & Restart of InDesign?

                       

                      Cheers

                      Juergen

                       

                      Hi Juergen,

                       

                      Thanks for your feedback. I haven't seriously studied keyboard shortcuts issues but I know this is a very complicated topic to scripters. What we can guess is that temporarily removing/refreshing menu actions—as my script does—does not preserve the existing KB shortcuts, because InDesign dynamically clears them as soon as the 'link' is broken between a shortcut and a custom action—I suppose. So we need to restore removed shortcuts, but AFAIK the scripting DOM does not provide any interface do do that. I don't even know if rewriting on the fly the 'indk' file could actually work. Maybe other people here have already investigated this point.

                       

                      @+

                      Marc

                      • 48. Re: [JS] Menu Added via Scripting Moves
                        Harbs. CommunityMVP

                        Yes. Menu Actions are saved cross-session. They are cleared out on shutdown only if there's no associated menu item.

                         

                        If you remove it and create a new one, keyboard shortcuts are lost.

                         

                        I'm pretty sure you should be able to add and remove menu items without issues. The keyboard shortcuts are associated with the actions.

                         

                        Harbs

                        • 49. Re: [JS] Menu Added via Scripting Moves
                          Cenchen Community Member

                          Hi,

                           

                             Why the customized menuItems cannot displaying in "Edit->Menus...->category - > application menu"???

                               But it displaying customized submenu...

                           

                          Thanks.

                          1 2 Previous Next