Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Cancelling default DnD problem

    Dear Support,

    I have the following problem:
    I'm initiating a DnD from an Img to a panel. The drag is OK and the panel accepts the drop... but, as the panel is a VLayout, it removes the source icon (which I don't want) and inserts it into my panel... which I don't want either.
    I searched for a solution and found out that I could simply call the cancel() method of the drop event to avoid this; which I did. But then, the mouse behaviour, especially the cursor appearance is incorrect; until a click somewhere.

    To reproduce the problem, simply take your example at :
    http://www.smartclient.com/smartgwt/showcase/#effects_dd_create

    ... and change the following:
    - PieceBin extends VLayout instead of Canvas
    - cancel() the event in the DropHandler

    How can I get this DnD operation work as expected ?

    Thank you very much in advance,

    Thomas

    #2
    You should be able to avoid problems by turning off the default VLayout drag/drop behavior.
    Try setting canDropComponents, showDragPlaceholder and showDropLines to false

    Comment


      #3
      It does not work, or perhaps I still did something wrong. Here is an example, you can still drag and drop buttons from the blue panel to the red one:

      Code:
      package com.fircosoft.cdb.client.debugging;
      
      import com.smartgwt.client.widgets.Button;
      import com.smartgwt.client.widgets.events.DropEvent;
      import com.smartgwt.client.widgets.events.DropHandler;
      import com.smartgwt.client.widgets.layout.VLayout;
      import com.smartgwt.client.widgets.layout.VStack;
        
      public class DropProblem extends VStack {  
        
          public DropProblem() {  
                this.setCanAcceptDrop(true);
                this.setCanDropComponents(false);
                this.setShowDragPlaceHolder(false);
                this.setShowDropLines(false);
                this.setWidth100();
                this.setHeight100();
                this.setBackgroundColor("red");
                this.setMinHeight(200);
                
                VLayout source = new VLayout();
                source.setBackgroundColor("blue");
                source.addMember(new DraggableButton("Button1"));
                source.addMember(new DraggableButton("Button2"));
                source.addMember(new DraggableButton("Button3"));
                source.addMember(new DraggableButton("Button4"));
                this.addMember(source);
                
                this.addDropHandler(new DropHandler() {
      			
      			@Override
      			public void onDrop(DropEvent event) {
      				System.out.println("dropped");
      			}
      		});
                         
          }  
        
          class DraggableButton extends Button {
          	DraggableButton(String title) {
          		super(title);
          		this.setCanDrag(true);
          		this.setCanDrop(true);
          	}
          }
      }

      Comment


        #4
        If you call "event.cancel()" within your custom drop operation, in addition to having canDropComponents set to false, you should entirely suppress the default Layout drop behavior and be able to implement your own custom logic.

        Comment

        Working...
        X