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: search table view revisited



Rainer, thanks for the assist, but I don't think that's... IT. :-)

Here's the entry in the xcode docs:

scrollRowToVisible:

Scrolls the receiver vertically in an enclosing NSClipView so the row specified by rowIndex is visible.

- (void)scrollRowToVisible:(int)rowIndex


What I don't get is what sets the value of int, and what value should it be set to? I've tried just passing it the row index (although the method I used may have been flawed) and still got  an error message. This was a few days ago, and I suppose I should have noted the way I did it and the result, but it was something like this:


set int to theindex


and the error was something like "index 6 not understood" or something to that effect.


*sigh*


Right about now, I wish I had just forced my way through the cocoa docs instead of starting with what was already familiar as my entry point into the wonderful world of xcode. Not bashing ASS, here, but rather my poor understanding of cocoa. 


Thanks again, Rainer, I do appreciate the effort! I'll see if setting it back to IT does anything, but I'm pretty sure it's int.

Anyone else got a clue?

Joshua



On May 5, 2008, at 3:05 PM, Rainer Standke wrote:

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.

TIA!

Joshua

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

This email sent to email@hidden

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

This email sent to email@hidden

 _______________________________________________
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

References: 
 >search table view revisited (From: Joshua Whalen <email@hidden>)
 >Re: search table view revisited (From: Rainer Standke <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.