Question on AbsoluteDropController

90 views
Skip to first unread message

SG

unread,
Jun 18, 2009, 2:14:08 PM6/18/09
to gwt-dnd
Hi,

I have been trying to make the dnd library work for our application
that has an absolute panel that has to scroll when an object is moved
beyond its original size and ahve not been sucessful so far. I have
the css set up to scroll the panel on overflow. I just downloaded the
latest version of the library dnd-2.6.4 and played with it. I can see
that the library now has scrollIntoView and that widget locations now
take the scroll into consideration but the move method in the
AbsolutePositionDropController still calculates the desiredX and Y
positions by taking the dropTargetWidth and heights that dont reflect
the scrolling that happens once the widget starts moving, so the
positioner never moves beyond the initial size of the absolute panel.
Is there a way to change this behaviour?

Thanks,
Swathy

Fred Sauer

unread,
Jun 18, 2009, 4:14:12 PM6/18/09
to gwt-dnd


2009/6/18 SG <cgsw...@gmail.com>


Hi,

I have been trying to make the dnd library work for our application
that has an absolute panel that has to scroll when an object is moved
beyond its original size and ahve not been sucessful so far. I have
the css set up to scroll the panel on overflow. I just downloaded the
latest version of the library dnd-2.6.4 and played with it. I can see
that the library now has scrollIntoView and that widget locations now
take the scroll into consideration but the move method in the
AbsolutePositionDropController still calculates the desiredX and Y
positions by taking the dropTargetWidth and heights that dont reflect
the scrolling that happens once the widget starts moving, so the

I think you mean:
  the resizing that I want to happen once the widget starts moving, so the
rather than:
  the scrolling that happens once the widget starts moving, so the


I'd recommend using your own AbsolutePositionDropController (just copy/paste the code into your own class) and increase the size of the drop target as the desired position would cause the widget to overflow. You may need to look at the reset cache example http://allen-sauer.com/com.allen_sauer.gwt.dnd.demo.DragDropDemo/DragDropDemo.html#ResetCacheExample source code.

Hope that helps
Fred

 
positioner never moves beyond the initial size of the absolute panel.
Is there a way to change this behaviour?

Thanks,
Swathy





--
Fred Sauer
Developer Advocate
G
ooglInc.
1600 Amphitheatre Parkway
Mountain View, CA 94043
fre...@google.com



SG

unread,
Jun 18, 2009, 4:37:51 PM6/18/09
to gwt-dnd
Thanks for your quick reply. I actually meant to say "the scrolling
that happens when the object is moved beyond the original boundaries
(bottom and right) of the absolute panel". The current behaviour is
when a draggable widget is dragged beyond the right/bottom boundaries
my scroll bars extend and the widget moves but the positioner(the
dotted border that appears when you start moving) never moves beyond
the border. I found that if I change the onMove method in the
AbsolutePositionDropController, to not execute these two lines of code

draggable.desiredX = Math.max(0, Math.min(draggable.desiredX,
dropTargetClientWidth
- draggable.offsetWidth));
draggable.desiredY = Math.max(0, Math.min(draggable.desiredY,
dropTargetClientHeight
- draggable.offsetHeight));

I am able to move the positioner as well but there are other side-
effects, so just wanted to see if there was a cleaner way to do this.


On Jun 18, 1:14 pm, Fred Sauer <fre...@google.com> wrote:
> 2009/6/18 SG <cgswa...@gmail.com>
>
>
>
> > Hi,
>
> > I have been trying to make the dnd library work for our application
> > that has an absolute panel that has to scroll when an object is moved
> > beyond its original size and ahve not been sucessful so far. I have
> > the css set up to scroll the panel on overflow. I just downloaded the
> > latest version of the library dnd-2.6.4 and played with it. I can see
> > that the library now has scrollIntoView and that widget locations now
> > take the scroll into consideration but the move method in the
> > AbsolutePositionDropController still calculates the desiredX and Y
> > positions by taking the dropTargetWidth and heights that dont reflect
> > the scrolling that happens once the widget starts moving, so the
>
> I think you mean:
>   the resizing that I want to happen once the widget starts moving, so the
> rather than:
>   the scrolling that happens once the widget starts moving, so the
>
> I'd recommend using your own AbsolutePositionDropController (just copy/paste
> the code into your own class) and increase the size of the drop target as
> the desired position would cause the widget to overflow. You may need to
> look at the reset cache examplehttp://allen-sauer.com/com.allen_sauer.gwt.dnd.demo.DragDropDemo/Drag...
> code.
>
> Hope that helps
> Fred
>
> > positioner never moves beyond the initial size of the absolute panel.
> > Is there a way to change this behaviour?
>
> > Thanks,
> > Swathy
>
> --
> Fred Sauer
> Developer Advocate
> Google Inc.1600 Amphitheatre Parkway

Fred Sauer

unread,
Jun 18, 2009, 4:45:07 PM6/18/09
to gwt...@googlegroups.com
Does the setBehaviorConstrainedToBoundaryPanel(false) method on the drag controller help for what you're trying to do?

SG

unread,
Jun 18, 2009, 5:12:16 PM6/18/09
to gwt-dnd
Nope, I have that set to false but that doesn't help.
> fre...@google.com- Hide quoted text -
>
> - Show quoted text -

Fred Sauer

unread,
Jun 18, 2009, 5:32:47 PM6/18/09
to gwt...@googlegroups.com

I would go with this approach:

I'd recommend using your own AbsolutePositionDropController (just copy/paste the code into your own class) and increase the size of the drop target as the desired position would cause the widget to overflow. You may need to look at the reset cache example http://allen-sauer.com/com.allen_sauer.gwt.dnd.demo.DragDropDemo/DragDropDemo.html#ResetCacheExample source code.

SG

unread,
Jun 22, 2009, 2:16:04 PM6/22/09
to gwt-dnd
Thanks for you suggestion. I copied the AbsolutePositionDropController
and recalculated the width and height of the drop target in the onMove
method, and now it drags the positioner beyond the initial size when
the panel needs to scroll as expected. However, when I select the
draggable widget the next time it repositions it to a location that is
offset in width and height by the scroll width and heights (i.e.
ignores the scroll bars). I am assuming there is some other part of
the code that needs the same re-calculation, any pointers would be
great.

Thanks so much,
Swathy.

On Jun 18, 2:32 pm, Fred Sauer <fre...@google.com> wrote:
> I would go with this approach:
> I'd recommend using your own AbsolutePositionDropController (just copy/paste
> the code into your own class) and increase the size of the drop target as
> the desired position would cause the widget to overflow. You may need to
> look at the reset cache examplehttp://allen-sauer.
> com/com.allen_sauer.gwt.dnd.demo.DragDropDemo/DragDropDemo.html#
> ResetCacheExample source code.

SG

unread,
Jun 22, 2009, 2:46:39 PM6/22/09
to gwt-dnd
On looking into the issue a little more, I found that the x and y co-
ordinates calculated in the onMouseDown method in the MouseDragHandler
class are also offset by the width and height of the scroll bars (i.e.
x is actualX - scrollbarWidth and y is actualY - scrollbarHeight).
Could this be the root of the problem I am seeing?

Thanks,
Swathy.
> > - Show quoted text -- Hide quoted text -

Fred Sauer

unread,
Jun 30, 2009, 7:37:30 PM6/30/09
to gwt...@googlegroups.com
Subsequent drags should work just fine. During dragging you can reset the cache by following this example:

Fred

pedubreuil

unread,
Jul 5, 2009, 6:35:53 AM7/5/09
to gwt-dnd
Hello!

I think I have a problem similar... that I cannot fix!
My drop area is a vertical panel, so I use the controller given in the
demo 5: NoInsertAtEndIndexedDropController that extends
IndexedDropController. The boundary panel of the PickupDragController
is an AbsolutePanel.
It works fine when this drag area is at the top of my webpage; but
when I need to scroll down the page to access to the vertical panel, I
cannot drag&drop my widgets... The position of the drop area is not
refreshed, while the position of the drag is!

I have tried :

1) to add in the drop controller :
public void onMove(DragContext context)
{
((AbstractDragController) context.dragController).resetCache();
super.onMove(context);
}

2) dragController.setConstrainWidgetToBoundaryPanel(false);

But my problem is still there...
Swathy, you seems to have solved your problem... could you post your
code please?
Is there a simple way to fix that?

Pierre-Emmanuel



On 1 juil, 00:37, Fred Sauer <f...@allen-sauer.com> wrote:
> Subsequent drags should work just fine. During dragging you can reset the
> cache by following this example:http://allen-sauer.com/com.allen_sauer.gwt.dnd.demo.DragDropDemo/Drag...

Fred Sauer

unread,
Jul 6, 2009, 5:21:01 PM7/6/09
to gwt...@googlegroups.com
Pierre-Emmanuel,

Are you using gwt-dnd-2.6.4? There's a fix included there for issue 71, which may be what you are seeing:

Fred

Pierre-Emmanuel

unread,
Jul 7, 2009, 1:54:50 AM7/7/09
to gwt-dnd
Thanks for your answer, Fred!
Yes, I am using the last version.... I am also using gxt libraries,
but I don't think there are incompatibilities...
I have tried to change the dragStartSensitivity, without effect (to
check the problem of the issue 59); and the sample of the issue 71
does not seem to match with my problem.

Pierre-Emmanuel

Fred Sauer

unread,
Jul 7, 2009, 2:06:57 AM7/7/09
to gwt...@googlegroups.com
Would you have a small test case which demonstrates the problem?

Pierre-Emmanuel

unread,
Jul 7, 2009, 4:47:29 AM7/7/09
to gwt-dnd
I had unexpected difficulties to isolate the problem... In fact, I
have discovered that the HorizontalSplitPanel used to split the
webpage between the left navigation menu and the content causes
trouble!
GWT compiles it as 2 DIV, with the attribute overflow:auto ...
While the page content (right DIV) requires a scroll-bar, the
navigation menu (left DIV) does not.
So the scroll-bar is not for all the window... I think this is why the
drag area does not match with the drop area when the user scrolls down
on the DIV "content".

Do you think it is possible to avoid that?


On 7 juil, 07:06, Fred Sauer <fre...@google.com> wrote:
> Would you have a small test case which demonstrates the problem?
>
> ...
>
> plus de détails »

Pierre-Emmanuel

unread,
Jul 7, 2009, 5:06:10 AM7/7/09
to gwt-dnd
Here is a test case to show the problem :

public void onModuleLoad()
{
HorizontalSplitPanel root = new HorizontalSplitPanel();
root.setSplitPosition("30%");
Label leftDiv = new Label("LEFT DIV");
root.add(leftDiv);

VerticalPanel rightDiv = new VerticalPanel();
rightDiv.add(new HTML("RIGHT DIV<br/>--<br/>--<br/>--<br/>--<br/>--
<br/>--<br/>--<br/>--<br/>--<br/>--<br/>--<br/>--<br/>--<br/>--<br/>--
<br/>"));

AbsolutePanel boundaryPanel = new AbsolutePanel();
PickupDragController dragController = new PickupDragController
(boundaryPanel,false);
dragController.setBehaviorMultipleSelection(false);

VerticalPanel dropIndexedPanel = new VerticalPanel();
dropIndexedPanel.setSpacing(20);
IndexedDropController WorkflowDropController = new
IndexedDropController(dropIndexedPanel);
dragController.registerDropController(WorkflowDropController);

boundaryPanel.add(dropIndexedPanel);
rightDiv.add(boundaryPanel);
root.add(rightDiv);
RootPanel.get().add(root);

for(int i=0;i<10;i++)
{
Label current_widget = new Label("Widget no "+i);
current_widget.setHeight("50px");
dropIndexedPanel.add(current_widget);
dragController.makeDraggable(current_widget);
> ...
>
> plus de détails »

Fred Sauer

unread,
Jul 7, 2009, 6:00:22 PM7/7/09
to gwt...@googlegroups.com
Pierre-Emmanuel,

Thank you for the test case.

Would you mind also sending me your HTML and CSS files? I want to make sure I'm using the same mode: quirks/standards.

Also, is the issue limited to web mode, if so which platform are you on? If windows, which version of IE are you using?

Thanks
Fred
Fred Sauer
Developer Advocate
G
ooglInc.

Pierre-Emmanuel DUBREUIL

unread,
Jul 8, 2009, 2:51:59 AM7/8/09
to gwt...@googlegroups.com
Hello!

To do this test case, I have not modified the HTML and the CSS :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
.gwt-Label{background-color:red}
</style>  
<title>Test for DND</title>
<script type="text/javascript" language="javascript" src="debugdragdrop/debugdragdrop.nocache.js"></script>
</head>
<body>
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
</body>
</html>

The only requirement is to have a vertical scroll bar (so the height of your browser should not be too large). To test it, try to drag the last label and to drop it before the first one.
I have tested this test case with Chrome, Firefox and IE (last version of each), on Windows 7.

Pierre-Emmanuel


2009/7/7 Fred Sauer <fre...@google.com>

Fred Sauer

unread,
Jul 8, 2009, 10:48:54 PM7/8/09
to gwt...@googlegroups.com
Pierre-Emmanuel,

I tried with GWT 1.6.4 and gwt-dnd-2.6.4.jar and am still not able to reproduce.

Would you mind running a GWT compile and sending me your web app?

Attached is my project. Let me know if it works for you.

Thanks
Fred
Pierre.zip.rename

Pierre-Emmanuel DUBREUIL

unread,
Jul 9, 2009, 3:01:53 AM7/9/09
to gwt...@googlegroups.com
Hello.
I am using the same versions as you.
But why have you put in coments your lines 108 and 109? This HTML widget is very important because it forces the browser to add a vertical scroll before the DnD area... if despite that, you cannot reproduce the bug, you should increase the height of this HTML widget.


Pierre-Emmanuel

2009/7/9 Fred Sauer <fre...@google.com>

Fred Sauer

unread,
Jul 11, 2009, 4:46:44 PM7/11/09
to gwt...@googlegroups.com
Pierre-Emmanuel,

I commented those out while I was testing various things.

I am able to reproduce what I think is your problem now. Let me take a look at the cause and get back to you.

Fred
--
Fred Sauer
fr...@allen-sauer.com

Pierre-Emmanuel DUBREUIL

unread,
Jul 11, 2009, 4:59:17 PM7/11/09
to gwt...@googlegroups.com
Thanks to consider this issue, and good luck!

Pierre-Emmanuel

2009/7/11 Fred Sauer <fr...@allen-sauer.com>

Fred Sauer

unread,
Jul 11, 2009, 11:17:50 PM7/11/09
to gwt...@googlegroups.com
Pierre-Emmanuel,

Can you try gwt-dnd-2.6.5.jar? It includes a fix for the issue you reported.

Thanks
Fred

Pierre-Emmanuel DUBREUIL

unread,
Jul 12, 2009, 5:36:58 PM7/12/09
to gwt...@googlegroups.com
Hello Fred!

Thanks a lot for your work!
I cannot test it immediatly (because of holidays!), but that should be OK!

Best,

Pierre-Emmanuel


2009/7/12 Fred Sauer <fre...@google.com>

Fred Sauer

unread,
Jul 12, 2009, 9:40:06 PM7/12/09
to gwt...@googlegroups.com
Thanks. Let me know whether it does work for you once you get back.

Fred

Pierre-Emmanuel DUBREUIL

unread,
Jul 27, 2009, 11:58:15 AM7/27/09
to gwt...@googlegroups.com
Problem solved!

Thanks a lot!

Pierre-Emmanuel 


2009/7/13 Fred Sauer <fre...@google.com>

Dimitar Vasilev

unread,
Apr 11, 2017, 7:14:06 AM4/11/17
to gwt-dnd
Hello, i have a similar problem.
The widgets can't be dragged after the scrolling.
I'm using dnd:3.3.4, PickupDragController.
Any suggestions?
Reply all
Reply to author
Forward
0 new messages