Tag: Double-click
Flex HDividedBox/VDividedBox divider double-click event oddity
by admin on Dec.01, 2009, under Development, Flex, Software
I ran across an interesting case today while looking into an issue for someone else related to capturing the double-click event on the divider for a HDividedBox. It’s a little tricky to get the event to be captured by Flex. A quick search of the interwebs turned up nothing but people with the same issue. There is even an open bug in the Adobe Flex bug tracker(you have to login) that seems to be the exact issue, but there is no resolution named. Through some quick experimentation I figured out you can get it to work like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="588" applicationComplete="start()"> <mx:HDividedBox id="divBox" height="100%" width="99%" liveDragging="true" doubleClickEnabled="true"> <mx:Canvas width="50%"> <mx:Text text="Some example text" /> </mx:Canvas> <mx:Canvas width="50%"> <mx:Text text="Some example text" /> </mx:Canvas> </mx:HDividedBox> <mx:Script> <![CDATA[ private function start():void { divBox.getDividerAt(0).addEventListener(MouseEvent.DOUBLE_CLICK, handleDoubleClick); } private function handleDoubleClick(e:MouseEvent):void { Alert.show('Event captured!'); } ]]> </mx:Script> </mx:Application> |
The specific resolution was to enable liveDragging and add the event to the divider itself(most people try to set it on the doubleClick property of the DividerBox).
Hopefully this post will be helpful to some people out there with the same issue!