Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    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.

  • Users who have thanked Inigoesdr for this post:

    cardician (12-01-2009)

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •