Skip navigation
Replies 1 2 Previous Next
  • Currently Being Moderated
    Dec 18, 2011 12:07 PM   in reply to John Hawkinson

    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...

     
    |
    Mark as:
  • John Hawkinson
    5,572 posts
    Jun 25, 2009
    Currently Being Moderated
    Dec 18, 2011 3:00 PM   in reply to Harbs.

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 18, 2011 10:12 PM   in reply to John Hawkinson

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 18, 2011 10:38 PM   in reply to John Hawkinson

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 23, 2011 12:33 PM   in reply to Marc Autret

    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

     
    |
    Mark as:
  • John Hawkinson
    5,572 posts
    Jun 25, 2009
    Currently Being Moderated
    Dec 23, 2011 12:38 PM   in reply to JuMayr

    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.)

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 23, 2011 12:40 PM   in reply to John Hawkinson

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 23, 2011 4:09 PM   in reply to JuMayr

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 24, 2011 11:27 AM   in reply to Marc Autret

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2012 3:02 AM   in reply to Harbs.

    Hi,

     

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

         But it displaying customized submenu...

     

    Thanks.

     
    |
    Mark as:
1 2 Previous Next

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points