DanDev.com

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!

:, , , , , , , ,

3 Comments for this entry

  • rocksoccer

    hi,
    I think you miss one point You need to set the doubleClickEnabled of the BoxDivider to be true, otherwise it wont trigger the event listener at all.

  • admin

    Thanks for your reply Rocksoccer,

    You’re correct, I should have mentioned that you need to set doubleClickEnabled to true. I was more pointing out that if you -only- set the event it will not work as you might expect(like I did), and that you have to enable livedragging in order to capture it.

    Regards,
    -Daniel

  • Mark

    Thanks so much. Been stuck with this little problem for a few days.

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...