...

View Full Version : Double clicking divider in HDividedBox not detected



cardician
11-30-2009, 07:58 PM
Just as a disclaimer, I'm very new to flex development.

So I've got a webpage with a HDividedBox and a couple of frames. I'm trying to implement code so that when the user double clicks on the divider, the frame to the left automatically minimizes. Seems straight-forward. The problem is that when I double click on the divider, nothing happens and nothing seems to be detected. However, if I double click anywhere other than the divider I can get the code to run and the frame will minimize correctly. I'm hoping someone here can point out my undoubtedly glaring mistake. Here is the summarized code that I'm currently using.



<?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%" doubleClickEnabled="true" doubleClick="handleDoubleClick(event)">
<folders:Folders id="folders" width="15%" height="100%"</folders:Folders>
<mx:Canvas width="100%"></mx:Canvas>
</mx:HDividedBox>
<mx:Script>
<![CDATA[
private var divLoc:int;

private function start():void {
divLoc = 0;
}

private function handleDoubleClick(e:MouseEvent):void {
if (divLoc > 0) {
divBox.getDividerAt(0).x = divLoc;
divLoc = 0;
}
else {
divLoc = divBox.getDividerAt(0).x;
divBox.getDividerAt(0).x = 0;
}
}
]]>
</mx:Script>
</mx:Application>


Note that this is just quick and dirty code to verify that I can get the frame to minimize and to detect the double clicks. As I said, this code runs when I double click anywhere within the HDividedBox, but not when I specifically double click on the divider itself. Then nothing happens.

Any help would be tremendous, thank you.

Inigoesdr
12-01-2009, 04:10 PM
If you want to get the double-click event ONLY on the divider you can do this:

<?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">
<!-- this namespace isn't defined <folders:Folders id="folders" width="15%" height="100%"</folders:Folders>-->
<mx:Canvas width="50%">
<mx:Text text="fillfillfillfillfillfill" />
</mx:Canvas>
<mx:Canvas width="50%">
<mx:Text text="fillfillfillfillfillfill" />
</mx:Canvas>
</mx:HDividedBox>
<mx:Script>
<![CDATA[
private var divLoc:int;

private function start():void {
divLoc = 0;
divBox.getDividerAt(0).addEventListener(MouseEvent.DOUBLE_CLICK, handleDoubleClick);
}

private function handleDoubleClick(e:MouseEvent):void {
if (divLoc > 0) {
divBox.getDividerAt(0).x = divLoc;
divLoc = 0;
}
else {
divLoc = divBox.getDividerAt(0).x;
divBox.getDividerAt(0).x = 0;
}
}
]]>
</mx:Script>
</mx:Application>
If you want it to register everywhere just add livedragging to your existing code.

cardician
12-01-2009, 07:18 PM
Thank you so much! That worked perfectly!

After doing some more research, I was trying to implement the double click by detecting two dividerPress events within 200ms and the code was getting crazy and convoluted. Not to mention not working properly. It seemed from Adobe's own forums that the double click not being detected on the divider is a bug and due to job contraints I'm stuck using Flex 2.0.1 and thought this might be my only solution. However, your answer worked 100% and due to my limited knowledge of flex I probably never would have come across it myself. Again, thank you.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum