Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

VerticalPanelDropController index of Positioner is alway -1 #181

Open
GoogleCodeExporter opened this issue Mar 13, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

I am using a VerticalPanel with a VerticalPanelDropController. My example is 
similar to this demo: https://gwt-dnd.appspot.com/#InsertPanelExample

Here is what I did: 

    columnDropController = new VerticalPanelDropController(
        columnContentPanel) {


        @Override
        public void onPreviewDrop(DragContext context)
            throws VetoDragException {
                 super.onPreviewDrop(context);
                 int newIndex = dropTarget.getWidgetIndex(newPositioner(context));
            } 

       }

It turns out that newIndex is always -1. I find the problem for this.  

When you print the widgets in the vertical panel the positioner is something 
like: 

<div class="dragdrop-positioner"><div style="width: 1358px; height: 
81px;"></div></div>


When you print the positioner widget with; GWT.log("newPositioner(context): 
"+newPositioner(context));

then you get something like: 

<div class="dragdrop-positioner" style="position: absolute; left: -500px; top: 
-500px;"><div style="width: 1358px; height: 81px;"></div></div>

Since the two outputs are not the same you will not get the correct position. 
Thus, I have to compute the coorect index like the following code did: 

int newIndex = -1;
        String positionerClass = newPositioner(context).getElement().getClassName();
        for (int i=0; i < dropTarget.getWidgetCount(); i++) {
            String widgetClass = dropTarget.getWidget(i).getElement().getClassName();
            if (widgetClass.equals(positionerClass)) {
            newIndex = i;
            }
        }









Original issue reported on code.google.com by michael....@googlemail.com on 3 Jul 2014 at 8:02

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant