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: Some Table View Question



Andreas,

Well, if you know some way to get the row number you want to select, you can use this to select and scroll to it:

on scrollTableToRow(tableView, rowToScrollTo)

set rowHeight to get (row height of tableView) + (item 2 of (get intercell spacing of tableView))
set visibleRect to get visible rect of tableView
set viewableRows to ((item 4 of visibleRect) - (item 2 of visibleRect)) / rowHeight
set maxRows to count of data rows of data source of tableView
set firstDisplayRow to rowToScrollTo - (viewableRows / 2)
if firstDisplayRow is less than 0 then set firstDisplayRow to 0
set lastDisplayRow to rowToScrollTo + (viewableRows / 2)
if lastDisplayRow is greater than maxRows then set firstDisplayRow to maxRows
call method "scrollRowToVisible:" of tableView with parameter firstDisplayRow
call method "scrollRowToVisible:" of tableView with parameter lastDisplayRow
call method "scrollRowToVisible:" of tableView with parameter rowToScrollTo - 1
-- subtracted 1 since this method is 0-based, while incoming parameter is 1-based
return true


end scrollTableToRow

The problem you'll have is that it is hard (I don't know how) to get the _row number_ of the data row you want using the "whose" clause. I can use that to get the data row id, but not the number. Very frustrating. You may need to actually loop over the data items to get the one you want - that's the wya I'm doing it.
---
Daniel A. Shockley
email@hidden
http://www.danshockley.com



Date: Wed, 27 Oct 2004 20:34:59 +0200
From: Kiel <email@hidden>

Hi,

I think my question has been discussed before, but I can't find an
answer.
Is there a possibility to programmatically select a row in a table view
after it has been found in the data source of the table view.
The thing I want to do is to find a data row with "whose content of
data cell x of it = mySearchItem" and then automatically scroll to this
row and select it in the table view.

-- _______________________________________________ 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.