Flex中如何通过doubleClickEnabled属性监听按钮(Button)doubleClick的例子
By Minidxer | January 1, 2009
接下来的例子演示了Flex中如何通过doubleClickEnabled属性,监听按钮(Button)doubleClick。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Script>
- <![CDATA[
- private function button_click(evt:MouseEvent):void {
- appendText(evt.type);
- }
- private function button_doubleClick(evt:MouseEvent):void {
- appendText(evt.type);
- }
- private function appendText(str:String):void {
- var now:Date = new Date();
- textArea.text += "[" + now.toTimeString() + "] " + str + "\n";
- textArea.validateNow();
- textArea.verticalScrollPosition = textArea.maxVerticalScrollPosition;
- }
- ]]>
- </mx:Script>
- <mx:ApplicationControlBar dock="true">
- <mx:Form styleName="plain">
- <mx:FormItem label="doubleClickEnabled:">
- <mx:CheckBox id="checkBox"
- selected="true" />
- </mx:FormItem>
- <mx:FormItem>
- <mx:Button id="button"
- label="[double] click me"
- doubleClickEnabled="{checkBox.selected}"
- click="button_click(event);"
- doubleClick="button_doubleClick(event);" />
- </mx:FormItem>
- </mx:Form>
- </mx:ApplicationControlBar>
- <mx:TextArea id="textArea"
- editable="false"
- width="50%"
- height="100%" />
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
Button |
No Comments » |
Tags: Button, click, doubleClick, doubleClickEnabled