Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > locking NSScrollView

locking NSScrollView
Thread Tools
Dedicated MacNNer
Join Date: Apr 2004
Status: Offline
Reply With Quote
Nov 19, 2005, 10:52 PM
 
I've got an NSScrollView that contains another view I'm looking at, and I want to prevent it from scrolling. I've taken away the scroll bars, so you can't scroll by clicking, but the mouse wheel still scrolls the view, even though there aren't any scroll bars.

Is there any way, short of removing the view from the scroll view temporarily (I should explain that this view has two 'states' that it can be in. In one, I want it to scroll, and it draws one way. In the other mode, it draws itself differently, and doesn't allow the user to scroll), for me to make it so that the scroll view can't scroll?
     
Fresh-Faced Recruit
Join Date: Nov 2001
Location: home
Status: Offline
Reply With Quote
Nov 22, 2005, 07:05 PM
 
I don't know any way to stop a NSScrollView from scrolling (that's what it's supposed to do.) But to keep the mouse wheel from vertical scrolling, this might work:
[myScrollView setVerticalLineScroll: 0.0];
[myScrollView setVerticalPageScroll: 0.0];
     
Dedicated MacNNer
Join Date: Apr 2004
Status: Offline
Reply With Quote
Nov 22, 2005, 08:11 PM
 
AH... genius. much better than my solution of making a new class called LockableScrollView, which could be set to lock, and when it was would not respond to the scroll wheel. Your idea is much better, except one little thing...

The scroll wheel seems to only scroll by line, so there's no need to set the Page scroll. Even if there was, you go about it wrong, because 0.0 means that the whole page would be refreshed. better would be to:

[myScrollView setPageScroll:[myScrollView contentSize].height];

which would set the Page scroll to just show the same area (page scroll seems to work by the value that you put in is the number of pixels of the currently displayed area to leave on screen (I may not have units right), so this would be saying, get the height of the currently displayed area, and leave that many pixels on screen when scrolling vertically.

Thanks though... it works like a charm (I'm just setting the lineScroll, seems to work)... Cheers!!!!!!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:43 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2