Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting changed cell values in a table



Hi All,

Following up an old problem, that I've since discovered was also posted (though not quite the same, so hard to find) by others, with no previous solution. I've appended my original post below, along with those by some others (Kevin Meaney, Michael Roloff and Mark Butcher), in case it helps someone else searching archives.

I discovered that the "cell value changed" (and similar events) does actually work for some of my tables. And Robert DuToit replied to this list:

I use this handler in my app and it works great for detecting a change to a cell value and then changing other cell values in that row to correlate. Yes you need a data source for this one.

So I set about isolating the problem. It turns out that the event is incomplete, lacking the tableColumn value, if it is sent from a table column that was created dynamically. It works fine with a table that you set up completely in Interface Builder, but if you "make new table column" to add columns to it, then the "cell value changed" event sent from cells, in those added columns, lack the tableColumn parameter. Further investigation of the properties of existing versus added table columns revealed that the added columns have a "missing value" for the table view. So since the table view is not defined, that must be why the table column specifier can't be put together and sent with the event (eg table column 2 in table view missing value...).


This seems to be a bug in the "make new table column command" in Xcode.

So, the solution is to set the table view property of the table column after making a new table column, such as:

tell myTableView
make new table column at end in table columns with properties {name:"columnName"}
set table view of last table column to myTableView
end tell


Then the various events triggered by changing the column or cells in it, work! At least for the ones I've tried.

Note that trying to incorporate it into the make properties doesn't work:

make new table column at end in table columns with properties {name:headerName, table view:myTableView}
-- fails


I now use this subroutine to make new table columns:

on MakeTableColumns(myTableView, headerList)
   delete every table column in myTableView

   set myDataSource to make new data source at end in data sources
   set data source of myTableView to myDataSource

repeat with headerN from 1 to count headerList
set headerText to item headerN in headerList
tell myTableView
make new table column at end in table columns with properties {name:headerText}
-- table view must be set for "on cell change" to return a table column value, but an Xcode bug omits it, so:
set table view of table column headerN to myTableView
set contents of header cell of table column headerN to headerText
end tell
tell myDataSource
make new data column at the end in data columns with properties {name:headerText}
end tell
end repeat
end MakeTableColumns


Tom

----
From: T&B <email@hidden>
Date: 20 December 2006 2:35:33 PM
To: AppleScript Studio <email@hidden>
Subject: The table column parameter is missing for change cell value

Hi all,

I have a table in a window and want to track changes by the user to cells in that table.

I'm trying to use either of these events/handlers, linked from Interface Builder:

change cell value

or:

cell changed value

which is supposed to provide the following, when the user alters a cell:

on change cell value theObject row rowN table column tableColumn value theValue

However, when run, I get this error:

The table column parameter is missing for change cell value.

If I remove the table column parameter, and use just:

on change cell value theObject row rowN value theValue

then the event is sent and received OK. But since I don't have the table column, I can't tell what cell is changing, so it's useless.

Is this a known bug?

How else can I find out what the user has changed in a table?

 ----
Date: 13 February 2006 11:29:38 AM +0100
From: Michael Roloff <email@hidden>
To: email@hidden
Subject: Table Columns

Hi All,

For a Project I needed to create the Columns of a TableView in code because the amount of Columns depends on some user Input.

I managed to do this with...
"repeat..."
"make new table column at end of table columns of table view "Table" of scroll view "Scroll" of window "Window" with properties {name:theName, identifier:theIdentifier}"
"set contents of header cell of last table column of table view "Table" of scroll view "Scroll" of window "Window" to theName"
"make new data column at end of data columns of theDataSource with properties {name:theName, sort order:ascending, sort type:alphabetical, sort case sensitivity:case insensitive}"


...and everything works so far.

Now I got two Questions.

To be able to change the Sort Order and the Sort Column of the Table I attached the "column clicked" Handler as outlined in the Documentation for "data source".
Now everytime I click a Column I got an error saying "The table column parameter is missing for column clicked. (-1701)".
It seems that because the Columns were created by code there is some information missing for Studio to actually "know" about the new Columns.
I tried to update the TableView with "update views of theDataSource" but that doesn't help.
...


 ----
Date: 7 September 2003 1:02:30 PM +0100
From: Kevin Meaney <email@hidden>
To: AppleScript Studio <email@hidden>
Subject: Dynamically created sortable table columns

G'day all,

I am dynamically creating columns as well as rows when needed, for both the table view and the data source. This all works fine but I cannot then sort the data as in the table sort example. To create a table the user can select the desired columns from a pre-defined set of columns
plus create new column types. I therefore cannot create all the possible columns using interface builder and then remove the ones I don't want.


I keep getting the:

The +class tabC; parameter is missing for +event daVScolC;. (-1701)

error message when I click on the table column and the: on column
clicked theObject table column tableColumn does not get called.

The table columns and and data columns are created using the code below.

set theDataSource to data source of table view
"tableviewqueryresults" of scroll view "scrollviewqueryresults" of
window "main"
delete every data row of theDataSource
delete every data column of theDataSource
tell window "main"
delete every table column of table view "tableviewqueryresults" of
scroll view "scrollviewqueryresults"
repeat with theColumn in the theTitles
set sortType to alphabetical
set theColumn to item i of theTitles
if (theColumn = "FileSize") or (theColumn = "BitDepth") or
(theColumn = "HorizDim") or (theColumn = "VerticalDim") or (theColumn =
"HorizResolution") or (theColumn = "VerticalResolution") then
set sortType to numerical
end if
make new table column at the end of the table columns of table
view "tableviewqueryresults" of scroll view "scrollviewqueryresults"
with properties {name:theColumn, identifier:theColumn}
set contents of header cell of table column i of table view
"tableviewqueryresults" of scroll view "scrollviewqueryresults" to
theColumn as string
-- The following line was just added in the vain hope that
setting the title might make it work.
set title of header cell of table column i of table view
"tableviewqueryresults" of scroll view "scrollviewqueryresults" to
theColumn as string
make new data column at the end of the data columns of
theDataSource with properties {name:theColumn, sort order:ascending,
sort type:sortType, sort case sensitivity:case insensitive}
end repeat
set sorted of theDataSource to true
set sort column of theDataSource to data column 1 of theDataSource


Suggestions as to what I am doing wrong or leaving out would be greatly
appreciated.

Kevin

----
Date: 24 March 2003 6:25:00 AM -0800
From: Mark Butcher <email@hidden>
To: AppleScript-Studio mail <email@hidden>
Subject: Adding columns to a table dynamically

I can add a new table column to a table in the script using the 'make' command, but there seems to be a problem with it. Please could someone let me know either how to do this, or if it cannot be done (present limitations with the 'make' command, maybe).

I want to be able to input a (math) matrix using a table. I don't know the number of columns of the matrix, so want to add columns to a table from the script. Having set the number of columns in IB to 3, I can add a 4th column with:

make new table column at end of table columns of theObject with properties {name:"4"}

Then I connect the data source and add rows, which enables me to enter the matrix elements into the table cells.

My problem is with the 'will display cell' handler, which subsequently gives the error:

The table column parameter is missing for will display cell. (-1701)

Help, anyone?

MarkB
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.