PDA

View Full Version : Disable scrolling by arrow keys and mouse wheel in a scrollpane


manojmathew
11-18-2005, 02:12 PM
Is it possible to disable scrolling by keys and mouse wheel in a scroll pane...?
This is creating a lot of headache in one of my projects. When ever the scrollpane has focus and any event from arrow keys or mouse wheel occures, the content of the scroll pane is moving.

I have added a listener object which catches all events from LEFT, RIGHT, TOP, and DOWN arrow keys and mouse wheel and used the Selection.setFocus(null) on this event. It is working almost fine except for mouse wheel. If the mouse is on the scrollpane mousewheel scrolls the content. I have used another method to prevent this. In the onEnterFrame event of the scrollopane content, I wrote the following code.

if(this._x!=0){
this._x=0;
}
if(this._y!=0){
this._y=0;
}



Again the problem is that it creates a small jerking. The scrollpane will scroll actually and after scrolling the movieclip detects the position and then restore it to 0;


Any other method to do this...?????

Ruben
11-18-2005, 09:07 PM
If you could find out what the name is of the listener that controls the onMouseWheel-event in the scrollpane-component then you could remove the listener (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary503.html) or set that event to null.

:) - Ruben

PS. If it helps you then here's the script I once used to attach actions to the scrolling-reel being used (http://www.actionscript.org/forums/showpost.php3?p=240183&postcount=22).

manojmathew
11-21-2005, 08:46 AM
Thanks.

But I couldn't find out the event handler for mouse wheel.

Now I am thinking of creating a custom scrollpane component without mousewheel enabled.

Ruben
11-21-2005, 09:15 AM
Yeah man, the standard scrollpane component sucks

:cool: - Ruben

loopap
10-06-2006, 09:25 AM
mouseListener = new Object();
mouseListener.onMouseWheel = function(delta) {
myScrollPane.vPosition = currentvPos;
}
Mouse.addListener(mouseListener);

currentvPos = myScrollPane.vPosition;
myScrollPane.onEnterFrame = function() {
currentvPos = myScrollPane.vPosition;
}

This did the trick for me :D

Mr. Belk
10-27-2008, 01:25 PM
This is quite an old topic, but maybe it will help somebody.

I was searching for some method, and for my own reasons I couldn't just block the scrollpane content - I needed it to be really prevented from getting its built-in onMouseWheel event. And I have found the simple thing - as far as you put some transparent movie clip over the scrollpane, it stops recieving exactly and only that event :cool: