To my relatively un-trained eye, the 'it' refers to the table view
that is the addressee of the tell block. And while I don't entirely
get what's going on either, that would make sense to me.
Hope this helps,
Rainer
On May 4, 2008, at 13:20 , Joshua Whalen wrote:
I recently posted a help request on this topic and got excellent
advice from <cleardot.gif><cleardot.gif>email@hidden:
There is a call method for scrolling to a particular row in a table
view: "scrollRowToVisible:". That is probably the key thing you are
missing. You pass the call method a row number (the row you want to
scroll to if that row is not already visible). You just need to
remember that this is zero-based, so 0 is the first row, 1 the
second etc.
There is also a call method, "indexOfObject:", (again, zero-based)
for getting the index of something in a list (array), so I might
well combine the two call methods. I would also select the row as
well as scrolling to it with "set selected row ...". Getting the
column contents to search on ... even if you haven't explicitly set
up an off-screen database, you can address the data as if you had.
Here is some sample code to show one way in which it could all go
together ...
set theList to {"zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten"}
set searchItem to "eight"
tell application "TableView"
set tableView to table view 1 of scroll view 1 of window 1
append tableView with theList
set columnContents to get content of data cell 1 of every data
row of data source of tableView
if columnContents contains searchItem then
set theIndex to call method "indexOfObject:" of object
columnContents with parameter searchItem -- zero-based
tell tableView
call method "scrollRowToVisible:" of object it with
parameter theIndex -- zero-based
set selected row to (theIndex + 1)
end tell
end if
end tell
Philip
The example is excellent, although I'm guessing it contains a type,
as follows:
call method "scrollRowToVisible:" of object it with
parameter theIndex -- zero-based
I'm guessing the object "IT" is actually object "INT". Reasonable
guess, I'd say.
I adapted the suggestion to my project as below:
on SearchMe(theitem, thetable)
log theitem & " this is the search item in searchme" & return &
return
set MyTableView to thetable
if MyTableView = "main" then
set thecellvalue to 2
set theDataSource to data source of table view 1 of scroll view 1
of window "main"
log "Schedule is the window that was called" & return & return
else
if MyTableView = "chooseplaylist" then
set thecellvalue to 1
set theDataSource to data source of table view 1 of scroll view 1
of window "chooseplaylist"
end if
end if
set searchcelldata to zap_the_crap("data cell " & thecellvalue & "
of every data row of table view 1 of scroll view 1 of window " &
MyTableView)
set columnContents to get contents of data cell thecellvalue of
every data row of data source of table view 1 of scroll view 1 of
window MyTableView --as list
if columnContents contains theitem then
set theIndex to call method "indexOfObject:" of object
columnContents with parameter theitem -- zero-based
log theIndex & " here's theindex!" & return & return
call method "scrollRowToVisible:" of object int with parameter
theIndex -- zero-based
log int & " this is INT" & return & return
set selected row to (theIndex + 1)
end if
end SearchMe
This works very nicely, for the most part. The logs show the correct
data being passed along the routine, etc..
The only problem is that actually running this returns this error:
"The variable int is not defined. (-2753)"
Now, my objective-c is not all it should be. I'm working on it,
honestly, but it's not all there yet.
Anyone want to offer a suggestion on how to define int?
This is one of two remaining problems to solve on a project that's
been dragging on for almost a year now. Once this is solved, I can
ship and pay my rent. So, I would be Oh, so greatful to solve this
in the next day or so. Sushi on me if you live in the tri-state as
soon as a sell a few of these.