Double click event not fired/triggered when double clicking on left side of tree node

I have the following Flex tree

<mx:Tree id="Tree" left="0" right="0" top="0" bottom="0" alternatingItemColors="[#EEEEEE, white]" dataProvider="{lsEspecie}" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true" labelField="item" labelFunction="tree_labelFunc" showRoot="false" doubleClickEnabled="true" doubleClick="Tree_DoubleClick(event)"> </mx:Tree>

When I double click on the ICON and to the right of side on any node, double click event is being fired as expected. But when clicking on any part of the left side of the node double click is not being fired

Double click event not fired/triggered when double clicking on left side of tree node

Is there any way to make the double click event fire when is happening to the left side of the node ?

-------------Problems Reply------------

Looks like a bug with mx:Tree. I added mouse over and mouse out handlers to my test application to trace what was going on. In certain cases double click was working in the red area you indicated and I saw that my mouse was over the Tree's selectionLayer. After I clicked and moved the mouse a bunch it would randomly stop accepting double-click and at that point my mouse was always over some SpriteAsset in the selectionLayer with mouseEnabled=true.

I fixed the problem by subclassing Tree and forcing all the children of the selectionLayer to have mouseEnabled=false:

import flash.display.InteractiveObject;
import flash.events.Event;

import mx.controls.Tree;
import mx.core.mx_internal;

use namespace mx_internal;

public class FixedTree extends Tree {

public function FixedTree() {
super();
}

override protected function createChildren():void {
super.createChildren();

getListContentHolder().selectionLayer.addEventListener(Event.ADDED, selectionLayerChildAddedHandler);
}

private function selectionLayerChildAddedHandler(e:Event):void {
// ListBase:5790 creates a SpriteAsset for the selectionLayer but does not set mouseEnabled to false

InteractiveObject(e.target).mouseEnabled = false;
}

}

I'm not 100% sure if this is the correct way to fix this bug but it got double click working for me and I don't see an side-effects yet.

You can create an itemrenderer for the tree and inside it add a doubleclick listener to its HGroup. eg-

protected function mxtreeitemrenderer1_creationCompleteHandler(event:FlexEvent):void
{
mygrp.addEventListener(MouseEvent.DOUBLE_CLICK,dblclk);
}

private function dblclk(event:MouseEvent):void
{
Alert.show("doubleclicked");
}
]]>
</fx:Script>
<s:states>
<s:State name="normal" />
<s:State name="hovered" />
<s:State name="selected" />
</s:states>
<s:HGroup id="mygrp" left="0" right="0" top="0" bottom="0" verticalAlign="middle">
<s:Rect id="indentationSpacer" width="{treeListData.indent}" percentHeight="100" alpha="0">
<s:fill>
<s:SolidColor color="0xFFFFFF" />
</s:fill>
</s:Rect>
<s:Group id="disclosureGroup">
<s:BitmapImage source="{treeListData.disclosureIcon}" visible="{treeListData.hasChildren}" />
</s:Group>
<s:BitmapImage source="{treeListData.icon}" />
<s:Label id="labelField" text="{treeListData.label}" paddingTop="2"/>
</s:HGroup>

Category:flex Views:5 Time:2013-11-28
Tags: flex

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.081 (s). 11 q(s)