dynamically create popup button (menu) in the window syntax?

This is a general question with respect to the UI for an application.

I’d like to be able to dynamically create a popup button (menu) in a window’s table column without having to have the element predefined in Interface Builder. Can I do this? Would I simply use some sort of code like this:

		-- Create a new popup button (ie. menu) to contain the allowed IRIS table:fields for mapping		
		set popupButtonMenu to (make new popup button "popupButtonMenu")
		tell popupButtonMenu
			repeat with tempItem in irisMappingDataTableFieldList
				make new menu item at end of menu items with properties {title:tempItem, enabled:true}
			end repeat
		end tell

Of course this causes an error. It’s not a valide AS event. Can anybody show me what I’ve done wrong?

If I can’t dynamically create popup buttons, can someone indicate in Interface Builder how I can put a popup button into a table column (for each row)? I’m not having any luck dragging the popup button onto the table column and getting it in there.

Thanks in advance,
Jack

You can’t create an element dynamically in code. To add a popup cell, in IB you drag the popup cell formatter to the header cell of the table column in which you want it placed (make sure it’s the header cell and not the body cell–the body cell won’t take). To see a finished example (including the proper code for manipulating popups once they’re in your table), see my TablePopupCells project in the misc. projects section of my site:

http://homepage.mac.com/jonn8/as/html/misc_projects.html

Jon

Jon,

Thanks for the help.

This may sound silly. But can you clarify what you mean by “popup cell formatter”? Are you referring to the NSPopUpButton icon on the the Cocoa Controls palette? I have tried dragging the item to the column heading after selecting it to make it the active element on the window. No matter where I drag the popup it just creates a new popup menu right on top of the table view that I’ve created.

Correction: I was just examining this again and realized I was using the wrong data control. I did not see the cell popup option under the Cocoa Data elements. I now have this working properly. Thanks again!

Thanks in advance,
Jack

http://macscripter.net/viewtopic.php?id=12930