Pop up button in a table view

I am trying to make a column of NSPopUpButton’s in a NSTableView and am having some troubles with it, I read this thread here and Apple’s developer page but neither have helped so far.

Something else I am needing to do is flush the table view, what would the best way to flush or delete all rows?

At the moment what I have is an app that will create some rows, that’s it. What I want it to do is to create those rows, then create the pop up buttons for each row, with values from a list that I’ll use another script to create. I want the rows to be listed before the pop ups because the list for the pop ups can take some time to create.

There’s also something in IB I haven’t been able to figure out, how do you change the size of the text that will be in the fields? The default is larger than the Table examples.

I finally made some breakthroughs and have solved some problems I was having.

I still have not figured out putting popups in the table view though, I am able to fill a column with them, but only from a defined list so they are all the same.

I’m also having a problem with how the window updates. Using this code:

on idle theObject
	mainFunction()
end idle

on clicked theObject
	if title of theObject is "Lookup" then
		mainFunction()
	end if
end clicked

Whether mainFunction is called on idle or on clicked, the screen will not update very often, including the progress indicator. Strangely, this is easily solved by pressing command-period whether it’s called on idle or on clicked. When it is called on clicked the button will remain blue until command-period is pressed.

You can take a look at this quick demo project I made to illustrate implementing popups in a table:

http://homepage.mac.com/jonn8/as/dist/TablePopupCells.sit

There are other demo projects on my site that may also be helpful:

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

Jon

Thanks for the reply Jon, I was hoping you’d find the time to reply.

Sorry, I wasn’t clear in my first post, I am trying to use NSPopupButtonCells, not NSPopupButtons in cells. This is what your example uses, the same one as in the thread I linked before and the one on Apple’s mailing list. They all use the same values for the popup, I need to create dynamic variables for each popup. So far I’ve only been able to get the same popup in all rows like in the example.

There is another problem relating to the table view I’ve been offputting until now because I thought it would be solved when I completed the on selection changed handler. Unfortunately it didn’t fix it. If any part of the table view is clicked I will receive an “NSCannotCreateScriptCommandError (10)” error. The on selection changed handler works fine, responding correctly between error messages. Using select all does not produce an error, as no clicking is needed. The table currently works but it is a problem having the error dialog all the time.

Yeah, I’ve been down this path before. and to the best of my knowledge, there is no way to change the contents of the popup on a row by row basis. You can change the value from the set list but not the list of menu items itself. They are all linked to one PopupButtonCell in the header.

Jon

Are there any other avenues for options in a table view? Would it be possible to have just one popup outside the table and have it’s contents changed on selection changed?

Do you have any ideas on the possible causes of the “NSCannotCreateScriptCommandError (10)” errors? I thought I’d copied the “Table” example properly, It’s driving me crazy. It’s fully functional, it will just show the error whenever the table view is clicked.[/i]

I fixed the table view error by changing this is the on clicked handler:

if title of theObject is "<Title Attribute>" then

to

if name of theObject is "<AppleScript Name>" then

I used buttons to change the selected cells values, as dynamic popups aren’t available to AppleScript Studio.

The only problem persisting is the window updating. Before things are drawn to the table I will have this line:

tell window "mainWindow" to update

Problem is that the window almost locks up when it is doing something, the progress indicator doesn’t move, if a button was clicked it will remain blue until the task is done, the application will not come to the foreground when it’s icon is clicked in the dock. Pressing command-period will make the the window responsive, but it will either reset the script or it will reset it and stall.