2010-12-13 72 views
0

如果在文本控件旁边有一个DateChooser控件,并且您左键单击鼠标以选择文本,则继续按住鼠标按钮并在按下时按住鼠标按钮datechooser控件,selectedDate值将更改为您悬停的日期。我有用户遇到问题,并且由于两个控件接近而无意中发生。我无法找到一种方法来阻止这种影响。基本上我希望selectedDate只有在用户实际点击日历控件时才会改变。 mouseDown或单击。在这些事件中调用函数不会改变这种行为。我需要一种方法来禁止更改mouseUpEvent上的日期(我认为)。Flex 3 DateChooser控件 - MouseUp事件上的日期选择更改

回答

2

这是一个恼人的错误,因为您无法取消DateChooser上的事件。这里有一个可能的解决方案:

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600"> 
    <mx:Script> 
     <![CDATA[ 
      private function preventDateChooserBug(e:MouseEvent):void { 
       //set the mouseChildren property to false, not enabled because 
       //that could cause an irritating flickering when clicking the 
       //text input box for focus 
       dtc.mouseChildren = false; 

       //add the event listener to stage so we get the mouse up event even 
       //outside of the text input control 
       stage.addEventListener(MouseEvent.MOUSE_UP, function(e2:MouseEvent):void { 
        dtc.mouseChildren = true; 
       }); 

      } 
     ]]> 
    </mx:Script> 
    <mx:TextInput x="10" y="10" id="txt" mouseDown="preventDateChooserBug(event)" /> 
    <mx:DateChooser x="178" y="10" id="dtc" /> 
</mx:Application> 
+0

太棒了!这解决了它,我学到了一些东西。谢谢! – cheetoResearch 2010-12-14 13:52:00