• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do we make hierarchial menu?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do we make hierarchial menu?


  • Subject: Re: How do we make hierarchial menu?
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 15 Feb 2018 22:10:48 +1100

On 15 Feb 2018, at 7:42 pm, Takaaki Naganoya <email@hidden> wrote:
>
> How do we make hierarchical menu ?

Here's your createMenu() handler from the page you linked to modified to add a
submenu:

on createMenu(aList)
        set aMenu to current application's NSMenu's alloc()'s init()
        set aCount to 1

        repeat with i in aList
                set j to contents of i

                if j is not equal to "" then

                        if j = "Quit" then
                                set aMenuItem to (current application's
NSMenuItem's alloc()'s initWithTitle:j action:"actionHandler:" keyEquivalent:"")
                                --(aMenuItem's
setKeyEquivalentModifierMask:(current application's NSControlKeyMask))
                        else
                                set aMenuItem to (current application's
NSMenuItem's alloc()'s initWithTitle:j action:"actionHandler:" keyEquivalent:"")
                        end if

                else
                        set aMenuItem to (current application's NSMenuItem's
separatorItem())
                end if
                (aMenuItem's setTarget:me)
                (aMenuItem's setTag:aCount)
                (aMenu's addItem:aMenuItem)
                if j is "Takaaki" then
                        set newMenu to current application's NSMenu's new()
                        (aMenuItem's setSubmenu:newMenu)
                        set newMenuItem to (current application's NSMenuItem's
alloc()'s initWithTitle:"Yes" action:"actionHandler:" keyEquivalent:"")
                        (newMenuItem's setTarget:me)
                        (newMenu's addItem:newMenuItem)
                        set newMenuItem to (current application's NSMenuItem's
alloc()'s initWithTitle:"No" action:"actionHandler:" keyEquivalent:"")
                        (newMenuItem's setTarget:me)
                        (newMenu's addItem:newMenuItem)
                end if

                if j is not equal to "" then
                        set aCount to aCount + 1
                end if
        end repeat

        return aMenu
end createMenu


--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: How do we make hierarchial menu?
      • From: Takaaki Naganoya <email@hidden>
References: 
 >How do we make hierarchial menu? (From: Takaaki Naganoya <email@hidden>)

  • Prev by Date: How do we make hierarchial menu?
  • Next by Date: Re: How do we make hierarchial menu?
  • Previous by thread: How do we make hierarchial menu?
  • Next by thread: Re: How do we make hierarchial menu?
  • Index(es):
    • Date
    • Thread