After quite sometime investigating a problem related to the Tree component in Flex I found a nice and easy solution.
The problem:
In a Tree with custom drag and drop functionality and where some handlers would require a "preventDefault()" call on the triggered event, after a drop of an item in the Tree with enough items to show a vertical scroll bar the Tree would scroll responding to the mouse move even after the drag action was completed.
The solution:
Basically the Tree's default dragDropHandler, and I believe all list based components with drag & drop functionality, will not reset the drag scrolling if the default behaviour of the event was prevented.
A quick override of the default method to fix the problem. Simply extend Tree if you haven't done so already.
Example:
override protected function dragDropHandler( event : DragEvent ) : void
{
event.target.mx_internal::lastDragEvent = null;
event.target.mx_internal::resetDragScrolling();
if( event.isDefaultPrevented() )
{
return;
}
super.dragDropHandler( event );
}
Thanks to the author of the WILK blog, though of help propagating the solution would be nice.
Hope it helps people find the solution faster than me ;)
No comments:
Post a Comment