Lag in Updating Data Source when Table Data is Changed?

I’ve come across an odd snag in my project I’m hoping someone can provide me guidance with.

I have a 2 coulumn table view, the 1st column is a Button Cell, the 2nd Column is a Text Cell. I have a Data Source attached to the table view.

I have a “clicked” event handler attached to the button cell.

The “clicked” event handler gets the contents of the data source.

The Problem:

When the “clicked” event handler gets the contents of the data source, it doesn’t register the change that has just been made. For example, if my data source begins as

{{false, “Row 1”},{false, “Row 2”}}

and the user clicks the check box in row 1, the “clicked” event handler getting the contents of the data source returns:

{{false, “Row 1”},{false, “Row 2”}}

if the user then continues and clicks the check box in row 2, the event handler then returns:

{{true, “Row 1”},{false, “Row 2”}}

So the event handler is always one behind. It doesn’t see the change the user just made, but it does see previous changes.

Any ideas on how to write the event handler to make the data source update itself immediately?


and here’s the event handler, for the sake of clarity:

get contents of every data cell of every data row of data source of table view “MyTable” of scroll view “MyScroll” of window “main”
log result

I couldn’t get the data source to update properly either. Telling the data source to update caused an error and tell the table view to update had no effect. A workaround (although kludgy) is to also enable the “clicked” handler for the table view as well as for the button cell. In your script, duplicate the get & log commands. When you click the button cell, it’s clicked handler will be run first and then the table’s will be run and on the table’s, the proper state of the button in the data source will be returned. For clarification, I made a quick project demonstrating this. You can download it from:

[url=http://homepage.mac.com/jonn8/as/dist/update_ds.hqx] http://homepage.mac.com/jonn8/as/dist/update_ds.hqx[/url]

Of course, you could just use the clicked handler for the table view alone and not attach any handler to the button cell. Doing this will return the proper data source results.

Jon

Jon,

thanks. i didn’t think of using the table view clicked handler.

your example project won’t work for me as is, because i only want things to proceed if the user has actually changed the setting of one of button cells.

i’m thinking i’ll do something along the lines of having a variable set to false, and have the button cell event handler set it to true. then, the table view event handler will go about its business only if the variable is set to true, and then reset the variable to false once it’s done.

thanks as always for your help. you really know your way around in these woods.