如果我从组件中拖动textInput并将其放在另一个组件的末尾附近,则textInput将超出dropZone。
有任何想法如何解决这个问题?
谢谢
编辑:
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="150" height="500" xmlns:components="components.*" >
protected function textInput_mouseDownHandler(event:MouseEvent):void
{
var dragI:Label=event.currentTarget as Label;
var ds:DragSource=new DragSource();
ds.addData(dragI,"TextInput");
DragManager.doDrag(dragI,ds,event);
}
<s:BorderContainer width="100%" height="100%">
<s:layout>
<s:VerticalLayout gap="10"/>
</s:layout>
<s:Label text="TextInput" mouseMove="textInput_mouseDownHandler(event )" dragComplete="dragCompleteHandler(event)" />
</s:BorderContainer>
和dropZone组件:
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" height="500" width="700" xmlns:components="components.*" >
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
protected function dragDropHandler(event:DragEvent):void
{
if (event.dragSource.hasFormat("TextInput")){
var draggedText:TextInput=new TextInput();
draggedText.x = event.currentTarget.mouseX;
draggedText.y = event.currentTarget.mouseY;
event.currentTarget.addElement(draggedText);
}
}
protected function dragEnterHandler(event:DragEvent):void
{
if(event.dragSource.hasFormat("TextInput") )
{
var dropTarget:BorderContainer= event.currentTarget as BorderContainer;
DragManager.acceptDragDrop(dropTarget);
}
}
<s:BorderContainer width="100%" height="100%" dragDrop="dragDropHandler(event)"
dragEnter="dragEnterHandler(event)"/>
</s:Group>
答案 0 :(得分:0)
http://saturnboy.com/2009/08/drag-and-drop-flex-4/
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf64595-7fff.html
答案 1 :(得分:0)
在布局对象上,将clipAndEnableScrolling设置为true。这将导致布局剪切所有内容,这些内容位于容器的边界之外。如果需要滚动,则仍需要将组包装在滚动条中。
<s:BorderContainer width="100%" height="100%">
<s:layout>
<s:VerticalLayout gap="10" clipAndEnableScrolling="true"/>
</s:layout>
<s:Label text="TextInput" mouseMove="textInput_mouseDownHandler(event )" dragComplete="dragCompleteHandler(event)" />
</s:BorderContainer>
clipAndEnableScrolling是所有布局的属性,VerticalLayout,HorizontalLayout和BasicLayout,仅举几例。