Scroll bar always starts at the bottom.

Help please!
I have an application I’m writing which opens a window called Student’s Files. All is working well, except that on the first opening after launch the scroll handle of the new window always goes to the bottom of the window. Since the matrix in the the scroll view has 100 elements, this means that the user has to scroll manually to the top.

I’ve tried the following, none of which work:

call method “scrollRangeToVisible:” of object (matrix"studentfiles" of view “studentsfiles” of scroll view “studentsfiles” of window “studentsfiles”) with parameter {0, 0} – found this one on the forum, but nothing happens!

scroll matrix"studentfiles" of view “studentsfiles” of scroll view “studentsfiles” of window “studentsfiles” to top – this produces a 'can’t handle command" error

scroll scroll view “studentsfiles” of window “studentsfiles” to top – this produces a 'can’t handle command" error

Various variations of the above

I’ve also tried using the text field “studentnames” (which is at the top of the view) as the reference, instead of matrix “studentfiles”.

I also feel that there must be a setting, either in the script or in Interface Builder, whih makes the window open with the scroll handle at the top>

Any suggestions, please - I’m sure it will be a simple solution - it usually is! As I’ve said everything else is working fine.

Greetings from Scotland UK!

Model: Mac Powerbook G4
AppleScript: Xcode 2.4
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

I think the correct call is this method of NSMatrix:

scrollCellToVisibleAtRow:column:

so (without having tried it) I’d say:

call method "scrollCellToVisibleAtRow:column:" of (matrix "studentfiles" of view "studentsfiles" of scroll view "studentsfiles" of window "studentsfiles") with parameters {theRow, theColumn}

where theRow/theColumn specifies the coordinates of the cell you want to scroll to.

to get the total number of rows you can use this:

set totalRows to call method "numberOfRows" of (matrix "studentfiles" of view "studentsfiles" of scroll view "studentsfiles" of window "studentsfiles")

The coordinates of the last row of the first column will probably be {totalRows-1, 0} then …

D.

That does it! Very many thanks! :smiley:

Mike

The other thing, if you happened to mess around with the scroll box in IB, it will start where you set it. (I had that problem with tab views, I don’t know if it’s the same for scroll boxes, though)

Yes, I probably did mess around with it in some way, but I couldn’t see anything to adjust to “un-mess” :slight_smile:

Mike