Flex 3 DateChooser 控件 - MouseUp 事件上的日期选择更改

发布于 2024-10-07 07:27:20 字数 256 浏览 3 评论 0原文

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

If you have a DateChooser control next to a text control and you left click your mouse to select the text then continue holding down the mouse button and letting the mouse button up while over the datechooser control, the selectedDate value changes to the date you are hovering over. I have users that are having issues with this and it happens unintentionally because of the proximity of the two controls. I cannot find a way to stop this effect. Basically I would want the selectedDate to only change if the user actually clicks the calendar control ie. mouseDown or click. Calling functions in those events do not change this behavior. I need a way to disable the control from changing the date on the mouseUpEvent (I think).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凡间太子 2024-10-14 07:27:20

这是一个令人恼火的错误,因为您无法取消 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>

That's an irritating bug because you cannot cancel events on the DateChooser. Here is a possible solution:

<?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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文