4 Replies Latest reply on Dec 8, 2009 11:33 AM by flairjax

    Stopping s:Vslider form responding to mouseWheel

    flairjax Level 1

      So I have an app with a Vslider in it.  For some odd reason if I use the Vslider thumb and drag it. Then move my mouse over some other part of the app and use my mouseWheel the Vslider changes based on my mouseWheel.  I have focusEnabled=false on my Vslider. I have event done the following but nothing works.  I don't want the Vslider to ever move if the mouseWheel is used.  I have event tried to extend Vslider and override the focusInHandler and focusOutHandler so they don't respond to mouseWheeling.

       

       

       

      mySlider.thumb.addEventListener(MouseEvent.MOUSE_WHEEL, preventEventProp, false, 999);
      mySlider.track.addEventListener(MouseEvent.MOUSE_WHEEL, preventEventProp, false, 999);

       

      private function preventEventProp( event:Event ) : void
                  {
                      event.preventDefault();
                      event.stopImmediatePropagation();
                  }

       

      <s:VSlider
                  focusEnabled="false"
                  height="95%"
                  maxHeight="140"
                  id="bzoom"
                  minimum="{ZOOM_MIN}"
                  maximum="{ZOOM_MAX}"
                  liveDragging="true"
                  change="updateVScale(event)"
                  click="stopProp(event)"
                  mouseDown="stopMouseDown(event)"
                  mouseUp="stopMouseUp(event)"
                  mouseWheel="preventEventProp(event)"
                  thumbDrag="stopProp(event)"
                  snapInterval=".10"
                  showDataTip="true"   
                   top="25"
                   left="4.5"
                  keyDown="stopProp(event)"
                  keyUp="stopProp(event)"
                  skinClass="assets.style.skins.CustomVSliderSkin"/>

       

       

      Thanks, J

        • 1. Re: Stopping s:Vslider form responding to mouseWheel
          Flex harUI Adobe Employee

          I'd probably grab the event in capture phase.

           

          If you have a simple test case, please file a bug.

           

           

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: Stopping s:Vslider form responding to mouseWheel
            flairjax Level 1

            Looks like I got it to work.  Will keep testing but looks good if you have the preventDefault after I stop the event

             

            So

             

            event.stopImmediatePropagation();
            event.preventDefault();

             

            instead of

             

            event.preventDefault();

            event.stopImmediatePropagation();

            • 3. Re: Stopping s:Vslider form responding to mouseWheel
              flairjax Level 1

              Ok, nope didn't work.  Back to the drawing board.


              • 4. Re: Stopping s:Vslider form responding to mouseWheel
                flairjax Level 1

                Ok so found the issue.  In our app we have a footer bar, like Facebook, that is always on top, thus Flash isn't on top. So I have to manually throwing mouseWheel events over from Javascript > then do a stage.getObjectsUnderPoint and find out what is under the mouse > then broadcast the event like so

                 

                public function handleWheels(event:Object): void {
                                //trace(event);
                                var obj:InteractiveObject = null;
                                var objects:Array = stage.getObjectsUnderPoint(new Point(event.x, event.y));
                                for (var i:int = objects.length - 1; i >= 0; i--) {
                                    if (objects[i] is InteractiveObject) {
                                        obj = objects[i] as InteractiveObject;
                                        break;
                                    } else {
                                        if (objects[i] is Shape && (objects[i] as Shape).parent) {
                                            obj = (objects[i] as Shape).parent;
                                            break;
                                        }
                                    }
                                }
                               
                                if (obj) {
                                    var mEvent:MouseEvent = new MouseEvent(MouseEvent.MOUSE_WHEEL, true, true,
                                        event.x, event.y, obj,
                                        event.ctrlKey, event.altKey, event.shiftKey,
                                        false, -Number(event.delta));
                                    if( obj is com.myapp.view.components.ZoomSlider ) { return ; }
                                    obj.dispatchEvent(mEvent);
                                }
                            }

                 

                So the above code BOLD code was added, which didn't handle all cases so my Vslider was still responding to MouseWheel so I decided to extend the Vslider and override system_mouseWheelHandler function like so (empty).

                 


                        override protected function system_mouseWheelHandler(event:MouseEvent):void
                        {
                        }

                 

                 

                Now the Vslider will not respond to the mouseWheel.

                 

                J