Modifying Popup Menu troubleshoot

I’m trying to modify a popup button’s menu items with add and delete buttons, but I can’t seem to get the delete to work. I get NSInternalScriptError (8) for this first script:


on choose menu item theObject
	if name of theObject = "myPopup" then
		tell window 1 of theObject
			set z to contents of popup button "myPopup"
		end tell
	end if
end choose menu item

on mouse up theObject
	if name of theObject = "delete" then
		set zTemp to z
		tell window 1 of theObject
			tell popup button "myPopup"
				set current menu item to first menu item
				delete menu item zTemp
			end tell
		end tell
	end if
end mouse up

I also tried:

   delete menu item whose titles are "menuItemToDelete"

and:


on mouse up theObject
	if name of theObject = "delete" then
		tell window 1 of theObject
			tell popup button "myPopup"
				delete current menu item
                            set current menu item to first menu item
			end tell
		end tell
	end if
end mouse up


I was able to “delete every menu item” and repopulate the menu in the “on launched” handler just fine.

Hi knarfin

the script you supplied below works fine for me, still mucking around with the top one.

on mouse up theObject
   if name of theObject = "delete" then
       tell window 1 of theObject
           tell popup button "myPopup"
               delete current menu item
set current menu item to first menu item
           end tell
       end tell
   end if
end mouse up

this works also

on mouse up theObject
	if name of theObject = "delete" then
		set zTemp to name of current menu item of popup button "myPopup" of window 1 as text
		tell window 1
			set current menu item of popup button "myPopup" to first menu item of popup button "myPopup"
		end tell
	end if
end mouse up

thanks for checking in to it. when using “delete current menu item” followed by “set current menu item to first menu item”, the menu item doesn’t appear to be removed from the menu and will still return its usual results, but when I try to delete it a second time, the debug app crashes with a signal 10 (SIGBUS) error.

I can only think that maybe a connection is not right in IB, you may need to clean and then build again, I
tested using debug and release with no issues, with one main window, one drop box and one button.