Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-30-2009, 06:58 PM   PM User | #1
cardician
New to the CF scene

 
Join Date: Feb 2007
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
cardician is an unknown quantity at this point
Double clicking divider in HDividedBox not detected

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.

Code:
<?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.
cardician is offline   Reply With Quote
Old 12-01-2009, 03:10 PM   PM User | #2
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
If you want to get the double-click event ONLY on the divider you can do this:
Code:
<?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.
Inigoesdr is offline   Reply With Quote
Users who have thanked Inigoesdr for this post:
cardician (12-01-2009)
Old 12-01-2009, 06:18 PM   PM User | #3
cardician
New to the CF scene

 
Join Date: Feb 2007
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
cardician is an unknown quantity at this point
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.
cardician is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:21 PM.


Advertisement
Log in to turn off these ads.