Friday, January 19, 2018

#1 2011-01-14 08:31:19 pm

fulmar2
Member
From:: Mountain View, CA
Registered: 2009-12-22
Posts: 14

Custom View in Scroll View scrolls to bottom by default.

How do I change this behavior?  I have a "custom view" in a "scroll view" in interface builder.  When I build the app, by default, the scroll view scrolls to the bottom.  I'd like for the scroll view to be scrolled to the top.  Also, I notice that the coordinates are "upside down"  Using Interface builder 3.2.5 (823) XCode Version 3.2.5 on an applescript studio app.

Thanks!


Filed under: view, scroll, down, Upside

Offline

 

#2 2011-01-24 06:58:54 pm

fulmar2
Member
From:: Mountain View, CA
Registered: 2009-12-22
Posts: 14

Re: Custom View in Scroll View scrolls to bottom by default.

Interestingly, I found another person with the same problem:
http://macscripter.net/viewtopic.php?id=18533

This post was kind of old, but it appears that this solution worked for them - but did not work for me (maybe due to having a newer version of xcode?)

Here is the purported solution (that does not work for me):

Applescript:


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

I tried that, with no luck.

Also Parrothead3 says, "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)"

I have played around with the scroll box in interface builder in every way i could imagine, and the scroll box still defaults to the bottom.

This is rather confounding.  I haven't encountered any other applescript solutions on the web.  There seems to be an objective-C solution, but I'm not sure how to implement that to test to see if it works...

Offline

 

#3 2011-02-25 03:34:22 pm

fulmar2
Member
From:: Mountain View, CA
Registered: 2009-12-22
Posts: 14

Re: Custom View in Scroll View scrolls to bottom by default.

OK, I finally got this, thanks to some help in the ASOC side of things.  Here is what I posted there (sorry for the double post, but it ended up getting a solution:

Ric -

Thank you for your reply.  This will definitely be useful to anyone using ASOC!

Applescript:


set x to 0
set y to calculatedHeightOfYourNSView -- Calculate the height of your NS view, or use a fixed value
call method "scrollPoint:" of object (view 1 of scroll view 1 of window 1) with parameter {x, y}

Above, I have re-written this for ASS, and will post this info in my other post as well.  The trick was:
For NSView, use "scrollPoint" (thanks, Ric, that was the key).  All of the other posts I had been looking at were for NSTextView, which is why "scrollRangeToVisible" and "scrollCellToVisibleAtRow" was not working!

Thanks again, Ric!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)