Adding a separator to a popup button

I’ve found a couple older posts on this subject:

http://macscripter.net/viewtopic.php?id=15565
http://macscripter.net/viewtopic.php?id=24602

but, as with my previous post, these deal with AppleScript Studio code. I need to know how to do this with AppleScriptObjC.

I believe I’ve got my subclass properly created as T2TObject. I’m just stuck on adding the separator to the end of my popup button (popCatList). “call method” obviously doesn’t work, so how do I do this now in AppleScriptObjC?

You probably need to make a separator menu item and add it your menu, something like:

set theSep to current application's NSMenuItem's separatorItem()
thePopup's menu()'s addItem_(theSep)

Sounds reasonable; unfortunately, this

popCatList's removeAllItems()
        popCatList's addItemWithTitle_("None")
        set theSep to current application's NSMenuItem's separatorItem()
        popCatList's menu()'s addItem_(theSep)
        popCatList's addItemsWithTitles_(catList)

doesn’t work, returning an error: “unrecognized function addItem_. (error -10000)”

I’ve tried a couple different variations of your snippet with no success. I just get “None”, whereas without attempting the separator I get “None” followed by by my list.

“menu” is an AS term, so to use it as a handler call you need to use pipes: |menu|()'s. This sort of thing is a good reason to edit scripts in an external editor rather than Xcode it self.

A response elsewhere showed me the solution:

"The word “menu” is an AppleScript class name. There are a few ASObjC methods that have the same name as an AppleScript keyword, so to use those you need to place the word in pipes, for example:

thePopUp's |menu|'s addItem_(theSep)