开发者

How to prevent changing tree selection?

I have a tree in Flex Application and one of the items is selected.

When a user clicks another item, I would like to make a check and possibly prevent the change of selection.

I tried catching click event and calling stopPropagation, and also itemClick with stopPropogation but both do not prevent selectedItem from changing.

Any ideas?

Edit 23/Mar - Adding source code. It's actually pretty straightforward:

<mx:Tree id="navTree"
    labelField="name"
    dragEnabled="false"
    itemClick="navTree_itemClickHandler(event)"
    itemRenderer="views.components.TopologyCustomTreeItemRenderer"          
    width="100%" height="100%"/>

And the event h开发者_如何学运维andler:

protected function navTree_itemClickHandler(event:ListEvent = null):void
{   
    if(navTree.selectedItem != null && event != null)
    {
        event.preventDefault();
        event.stopImmediatePropagation();
    }
}

After selection of the first item the tree should not allow to change selection. Yet the selection still changes.


Isn't <mx:Tree selectable="false"> what you're wanting to do?


I think you should use preventDefault() with stopPropagation or stopImmediatePropagation() or probably both

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜