开发者

Flex : stopPropagation of the event Keyboard.ENTER of a colorpicker

I have a WindowedApplication with a lis开发者_StackOverflowtener on keyboardEvent (on the ENTER key), but when the user choose to use the colorpicker and type an hexadecimal code then hit ENTER the event is propaged to my WindowedApplication too. I have to stop the propagation. Any hint or snippet ? thanks P.


<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:mx="library://ns.adobe.com/flex/mx" 
        keyDown="appHandler(event)">
 <fx:Script>
  <![CDATA[
   import mx.controls.Alert;
   import mx.events.FlexEvent;

   private function appHandler(event:KeyboardEvent):void
   {
    trace('A key has been pressed inside the app');
   }

   private function cpHandler(event:KeyboardEvent):void
   {
    trace('A key has been pressed inside the color picker');
    event.stopPropagation();
   }

  ]]>
 </fx:Script>

 <mx:ColorPicker x="159" y="137" id="cp" keyDown="cpHandler(event)"/>
 <s:TextInput x="233" y="137"/>

</s:WindowedApplication>


This is part of the code of the TitleWindow, where cp is the ColorPicker.

...     

public function init():void { cp.addEventListener(ColorPickerEvent.ENTER,handler); }

public function handler(e:ColorPickerEvent):void { e.stopImmediatePropagation(); }

public function changeColor(e:ColorPickerEvent):void { Application.application.couleur = cp.selectedColor; PopUpManager.removePopUp(this); } ...

And this is from my main mxml :

... employeeList.addEventListener(KeyboardEvent.KEY_UP, enterListener); ...

private function enterListener(e:KeyboardEvent):void {
if(e.keyCode == Keyboard.ENTER) {
if(employeeList.selectedItem) {
showDetail(employeeList.selectedItem as Employee);
}
}
}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜