DragDropLayouts disable dragging

Hi,

I’m using DragDropLayouts add-on.
My application is working perfectly except for one problem; I’m unable to disable dragging.

I have tested with two scenarios:
1: I’m able to start the application with drag mode set to LayoutDragMode.CLONE, everything works fine.
2: When I start the application with drag mode set to LayoutDragMode.NONE, dragging is disabled as expected.

In scenario 2 I am able to enable dragging after the initial start up.

However, in scenario 1, I am unable to disable dragging when the app is started with drag mode enabled (LayoutDragMode.CLONE).

Is there any way to make it work?
Anyone had this problem?

Thank you for reporting this issue.

It was a bug in DragDropLayouts and has been fixed in version 0.5.2.

As usual it can be downloaded from
http://vaadin.com/directory#addon/dragdroplayouts

Thank you, that works perfectly.

Is there any way to disable dragging of certain components that have been placed on a DDAbsoluteLayout, when others are still draggable?

I’m afraid not, currently dragging is made on a layout basis only.

Would make a nice feature addition though, maybe in the next version :slight_smile:

As of version 0.6 of DragDropLayouts you can use DragFilters on layouts to prevent certain components from being dragged :wink:

I think I’m being stupid, but how can I use the DragFilter to disable drag for a particular component added to a DDAbsoluteLayout?
Do you have any examples?

Here is a short example:


  // Create an absolute layout
 DDAbsoluteLayout layout = new DDAbsoluteLayout();
 
 // Enable dragging (of all) components
 layout.setDragMode(LayoutDragMode.CLONE);
 
 // Limit dragging to only buttons
 layout.setDragFilter(new DragFilter() {			
	public boolean isDraggable(Component component) {	
		return component instanceof Button;
	}
 });

The whole example can be found in the demo application at
http://john.virtuallypreinstalled.com/DragDropLayouts

Thanks, that’s excellent :smiley: