【问题标题】:Flex 3 DateChooser Control - Date Selection Changes on MouseUp EventFlex 3 DateChooser 控件 - MouseUp 事件上的日期选择更改
【发布时间】:2011-05-24 23:44:14
【问题描述】:
如果您在文本控件旁边有一个 DateChooser 控件,并且您左键单击鼠标以选择文本,然后在 datechooser 控件上方继续按住鼠标按钮并让鼠标按钮向上,则 selectedDate 值将更改为日期你悬停在上面。我有用户对此有疑问,并且由于两个控件的接近而无意中发生。我找不到阻止这种影响的方法。基本上,我希望 selectedDate 仅在用户实际单击日历控件时才更改,即。 mouseDown 或单击。在这些事件中调用函数不会改变这种行为。我需要一种方法来禁用控件更改 mouseUpEvent 上的日期(我认为)。
【问题讨论】:
标签:
apache-flex
datechooser
【解决方案1】:
这是一个恼人的错误,因为您无法取消 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>