Adobe Dreamweaver Forums



Last 10 THreads :         Renaming a project (Last Post : poverbo - Replies : 8 - Views : 15 )           »          Merged Projects Not Appearing in WebHelp TOC (Last Post : hermi14 - Replies : 4 - Views : 5 )           »          Sound.position (Last Post : kglad - Replies : 1 - Views : 2 )           »          Flash-PHP Mail Form (Last Post : kglad - Replies : 1 - Views : 2 )           »          Flash Controls Not Displaying in Embedded File (Last Post : kglad - Replies : 1 - Views : 2 )           »          Making a photo with rounded corners (Last Post : quality11 - Replies : 2 - Views : 3 )           »          Cookies and cflogin (Last Post : idesdema - Replies : 10 - Views : 11 )           »          DW Flash Encoder (Last Post : Hunter Elliott - Replies : 1 - Views : 2 )           »          DIV in Table not working. (Last Post : JoeyD1978 - Replies : 7 - Views : 8 )           »          Web Services (Last Post : DEnglsih - Replies : 0 - Views : 1 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 12-04-2008, 11:23 PM
AlexAAM
 
Posts: n/a
Diggs:
Default mouse wheel scroll question

Hello to all, i want to make the following question:
I have a canvas which has a vertical scroll bar, inside this canvas there is a
textarea control which has a vertical scroll bar too. That i want to make is:
when the user put the mouse cursor on to the textarea and use the mouse wheel
i want to make scrolling the canvas and not the textarea.

any help will be appreciated.
thanks in advance




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-05-2008, 05:02 PM
-Hob
 
Posts: n/a
Diggs:
Default Re: mouse wheel scroll question

You'll probably need to extend TextArea to get this to work and override
protected function mouseWheelHandler(). TextArea does an
event.stopPropagation() in its version of this function. If you override the
function and simply do nothing (do NOT call super.mouseWheelHandler()), that
might do the trick.

Reply With Quote
  #3 (permalink)  
Old 12-05-2008, 09:42 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: mouse wheel scroll question

You could try this:
1) Set textArea mouseChildren="false".
2) Add an eventListener to to the TextArea for its mouse wheel event when the
app loads.
3) In the listener, scroll the canvas component.
See attached code for a working example. Just be aware that if you do this,
users will NOT be able to scroll the textArea at all.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="initApp()" >
<mx:Script>
<![CDATA[
private function initApp():void{

textAreaLorem.addEventListener(MouseEvent.MOUSE_WH EEL,handleWheelEvent);

}
private function handleWheelEvent(event:MouseEvent):void{
var currentPosition:Number = canvasMain.verticalScrollPosition;
canvasMain.verticalScrollPosition = (currentPosition -
event.delta*3);
}
]]>
</mx:Script>
<mx:Canvas id="canvasMain" x="66" y="48" width="200" height="85"
verticalScrollPolicy="on" borderStyle="solid" borderColor="#FCE700">
<mx:TextArea id="textAreaLorem" x="10" y="0" height="141"
verticalScrollPolicy="on" mouseChildren="false">
<mx:text><![CDATA[Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Suspendisse urna ante, convallis nec, pretium quis, volutpat
in, ligula. Sed quis purus. Morbi dictum consequat sapien. Maecenas at eros.
Quisque venenatis felis et augue. Nullam gravida. Mauris est nunc, aliquet at,
pharetra et, lobortis nec, augue. Nulla facilisi. Nullam dictum. Ut quis neque.
In vitae tellus ac felis tincidunt rhoncus. Aliquam a ligula. Nullam auctor,
leo at imperdiet blandit, sem metus pulvinar velit, quis vehicula metus dolor
ac odio.

Morbi feugiat, lorem at pellentesque tristique, arcu elit accumsan urna, vitae
convallis leo orci nec nisl. Sed at est. Cras quis mi sed elit aliquam
eleifend. Nulla at sapien. Donec neque turpis, congue eu, tincidunt in, luctus
ut, lectus. Phasellus nibh risus, tincidunt sed, pellentesque id, tristique ut,
lacus. Suspendisse augue mi, mollis in, pretium id, gravida a, quam. In arcu
orci, ullamcorper vel, egestas a, convallis vitae, lacus. Sed nunc nunc,
condimentum quis, molestie sed, varius a, enim. Praesent condimentum luctus
velit. Ut placerat, metus in ornare lobortis, metus justo euismod odio, non
ullamcorper nisl nunc tincidunt orci. Proin vehicula.

Mauris aliquet, tortor molestie vulputate fermentum, ligula metus dignissim
orci, sed rutrum lorem lectus ut ipsum. Vivamus eu nisl eu tortor dignissim
faucibus. Nam egestas pretium massa. Sed id sapien non tellus fringilla
porttitor. Nam cursus, libero nec adipiscing laoreet, leo nisl congue orci, non
pellentesque dolor mi sed metus. Aliquam nibh. Morbi mollis malesuada est.
Maecenas quis tellus. Aliquam tellus ligula, auctor sed, suscipit sit amet,
faucibus non, pede. Nulla venenatis eleifend magna. Pellentesque in sapien.
Cras lorem ipsum, vehicula eget, dictum non, porttitor bibendum, leo. Cras
luctus venenatis neque. Nulla lobortis nisl sed felis.
]]></mx:text>
</mx:TextArea>
</mx:Canvas>

</mx:Application>

Reply With Quote


  #4 (permalink)  
Old 12-17-2008, 03:13 AM
AlexAAM
 
Posts: n/a
Diggs:
Default Re: mouse wheel scroll question

Thanks for the replies. The solution to my question is this:

package
{
import flash.events.MouseEvent;

import mx.controls.TextArea;

public class newTextArea extends TextArea
{
public function newTextArea()
{
super();
}

/*
override protected function createChildren():void
{
super.createChildren();
textField.mouseWheelEnabled = false;
}
*/

private var scrollAnterior:Number=-1;
private var direccionScroll:Number=0;
override protected function mouseWheelHandler(event:MouseEvent):void
{

var dirScroll:int = event.delta <= 0 ? 1 : -1;
if (verticalScrollPosition==scrollAnterior && direccionScroll==dirScroll)
return;
scrollAnterior=verticalScrollPosition;
direccionScroll=dirScroll;
super.mouseWheelHandler(event);
}

}
}

it works fine, but now i want to make the same with the canvas, but seems is
not possible override mouseWheelHandler event in it. Any help or suggestion ?

Thanks in advance

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 10:23 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk