2010-12-13 47 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