Hi!
I have a tab view with three tab view items, each only containing a popup button. I wanted to test if having just one popup button but changing it’s menu items would be any faster. The menu items all have images by default. So I tried :
make new menu item at end of menu items of menu of popup button "popup" of window "main" with properties {title:"Test", image:"TestImage"}
But this hangs. Everything is set correct because if I only change the title it works… The dictionary says :
menu item‚n [inh. item] : A menu item
elements
contained by popup buttons, menus.
properties
...
image (image) : the image for the menu item
...
But I can’t get it working…
Thanks in advance
“TestImage” looks like a string. You have to load the image and use that…
set myTestImage to load image "posix/path/to/image"
make new menu item at end of menu items of menu of popup button "popup" of window "main" with properties {title:"Test", image: myTestImage}
I didn’t test this on a popup button. I tested it on the main menu… but it should be basically the same. I added an image to my project called anImage.png.
set myResources to (path to me as Unicode text) & "Contents:Resources:"
set theImage to load image (POSIX path of myResources & "anImage.png")
set theMenu to menu "testMenu" of main menu
tell theMenu
set theMenuItem to make new menu item at end of menu items with properties {title:"New Menu Item", enabled:true, script:me}
end tell
set image of theMenuItem to theImage
I tried :
set myResources to (path to me as Unicode text) & "Contents:Resources:"
set theImage to load image (POSIX path of myResources & "MyImage.png")
tell menu of popup button "Popup" of window "main"
set theMenuItem to make new menu item at end of menu items with properties {title:"New Menu Item", enabled:true, script:me}
end tell
set image of theMenuItem to theImage
I got an error Can’t set <> id 6 of item id 5 to <> id 4. (-10006)
But I fixed it with:
set image of menu item 4 of menu of popup button "Popup" of window "main" to theImage
Thanks a lot !