Search code examples
javagwtdrag-and-dropgxt

GXT FramedPanel Drag for header


I want include Grid in FramedPanel and using gxt dnd.
But if I add FramedPanel in DragSource:

DragSource source = new DragSource(framedPanel) {
              @Override
              protected void onDragStart(DndDragStartEvent event) {
                super.onDragStart(event);
                event.setData(framedPanel);


              }
            };


DnD works when I click and hold on Grid. How I can do to DnD only worked on the header of FramedPanel.


Solution

  • Consider using Draggable instead of DragSource, then use the constructor that takes two arguments. This way you can specify the header as the 'handle' argument.

    Draggable draggable = new Draggable(framedPanel, framedPanel.getHeader());
    //assuming GXT 3, just guessing from your post
    draggable.addDragStartHandler(new DragStartHandler() {
      public void onDragStart(DragStartEvent event) {
        //...
      }
    });
    

    If you must use DragSource, subclass it to replace the Draggable instance, and create a new instance as specified above, plus making the changes found in the existing DragSource constructor.