Greetings everyone. Does anyone know how to create sub menus of main menu items? For example, I want to create a new menu in my application programatically…
make new menu at end of menus of main menu with properties {title:"Test", name:"Test", enabled:true}
…which works fine. But what I want to do is be able to create a sub menu of the ‘Test’ menu, and populate IT with menu items. Here’s a diagram…
I want “Item 1” and “Item 2” to be items in a sub menu of “Test” named “Menu 1”. I’ve tried all sorts of things and it doesn’t want to let me make submenu’s…only menu items. I’m looking for something along the lines of…
(* Create the sub menu *)
make new menu item at end of menu items of menu "Test" of main menu with properties {title:"Main 1", name:"Main1", enabled:true}
(* Create each menu item *)
make new menu item at end of menu items of menu item "Main1" of menu "Test" of main menu with properties {title:"Item 1", name:"Item1", enabled:true}
I realize that this should be streamlined, but I wanted to elaborate on my code so you could see exactly what I’m doing. I’ll take obj-c calls too, but I can’t see a way to use them either. Ultimately, I want to take a list of lists like {{“a”,“b”,“c”},{“x”,“y”,“z”}} and create a menu out of it’s contents like…
(* Create the sub menu *)
make new menu item at end of menu items of menu "Test" of main menu with properties {title:"Main 1", name:"Main1", enabled:true}
(* Create each menu item *)
make new menu item at end of menu items of menu item "Main1" of menu "Test" of main menu with properties {title:"Item 1", name:"Item1", enabled:true}
Is there a way to not only give the menu item an applescript name but also assign it an event handler like
with properties {title:“Item 1”, name:“Item1”, enabled:true , event handler: “choose menu item”}
hmmmm
make new menu item at end of menu items of menu “myMenu” of main menu with properties {name:“MyMenuName”, title:“MyMenuName”, enabled:true}
isn’t even working for me. I’m getting NSReceiverEvaluationScriptError: 4 (1)
What’s up with that?
Never mind about the 4 (1) error got that fixed. It wasn’t event that line that was causing it.
Would still like to know about setting the event handler though.