• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
weirdness with sorted datasource & call method editColumn on nstableview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

weirdness with sorted datasource & call method editColumn on nstableview


  • Subject: weirdness with sorted datasource & call method editColumn on nstableview
  • From: Michael Johnston <email@hidden>
  • Date: Tue, 28 Dec 2004 23:08:08 +0100

I have a table view that I want to be sorted. I also want to add new rows with a "+" button, and have the first data cell in the new row be hilited. This is done easily enough with <code>call method "editColumn:row:withEvent:select:"</code>

The difficulty comes when the data source is sorted. If I add a row, select the data row in the table view, then call editcolumn, the data source first sorts and the tableview updates, and the wrong row is (likely to be) hilited (even though I am setting the selection by id of the actual row created, not by index).

calling update on the table view before setting the selection. The weirdness is that looping through all rows and accessing BOTH the id AND the contents of a data cell in the row will cause everything to work as desired. Even weirder is that accessing ONLY the id, or ONLY the contents of a data cell, will cause everything to work as expected as long as the data source already has 2 or more rows when adding a row, but not when there is only one row in the table!

I find that somewhat odd and have no plausible explanation. Anyone??

on clicked theObject
append sectionColorsDataSource with newRow
set theTableView to table view "sectionColorsTable" of scroll view "sectionColorsTable" of tab view item "sectionColorsTab" of tab view "setupTabView" of window "processor"
set newRowId to id of last data row of sectionColorsDataSource


--update theTableView -- has no effect?!?!

-- somehow the following seems to cause the tableview to get in sync. but update does not. WHy???
repeat with aRow in every data row in sectionColorsDataSource
-- set sideEffect to (id of aRow) -- this will work once there is more than 1 row in the table, but not when adding the second row (whether at the begining, or by reducing to one row by deleting)
set sideEffect to (id of aRow) & (contents of data cell 1 of aRow) -- this works always
--set sideEffect to (contents of data cell 1 of aRow) -- this also works only when there is more than one row
end repeat


set selected data row of theTableView to (data row id newRowId of sectionColorsDataSource)
set theColumnIndex to 0
set theRowIndex to (selected row of theTableView) - 1 -- don't forget to convert Applescript 1-based index to rest-of-the-world 0-based index
set selectAll to true
call method "editColumn:row:withEvent:select:" of theTableView with parameters {theColumnIndex, theRowIndex, null, selectAll}
end clicked


Anyway, perhaps it is all a waste of time: the next problem I find is that tabbing to the next column triggers a re-sort, with the same row by index remaining selected. IE, when the table is sorting on column one and you enter an out-of-order value for the cell in column one, it will move, but the same physical row in the table will remain selected, meaning you are now editing the second column in a different data row.

Are sorted data sources simply unusable for tables that are editable? can I handle this somehow in a keyboard up handler, trapping the tab key?

Michael Johnston
Planetactive

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Subscribing to Ical calendars accross network
  • Next by Date: [AS & AW] class of selection
  • Previous by thread: Re: Subscribing to Ical calendars accross network
  • Next by thread: [AS & AW] class of selection
  • Index(es):
    • Date
    • Thread