Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » DragSource and Composite
DragSource and Composite [message #512707] Sat, 06 February 2010 12:04 Go to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Hello,

how can i use a hole composite as a DragSource?
		Composite composite;
		DragSource dragSource = new DragSource(composite, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY);
		Transfer[] transfers = new Transfer[] {new MyTransfer()};
		dragSource.setTransfer(transfers);
		dragSource.addDragListener(new DragSourceAdapter() {
			
			@Override
			public void dragStart(DragSourceEvent event) {
				
				System.out.println("start");
			}
			
			@Override
			public void dragSetData(DragSourceEvent event) {
				System.out.println("setData");	
			}
		});


It doesn't work... What is my mistake?

Thanks...

[Updated on: Sat, 06 February 2010 12:12]

Report message to a moderator

Re: DragSource and Composite [message #513033 is a reply to message #512707] Mon, 08 February 2010 10:32 Go to previous messageGo to next message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
Registered: July 2009
Senior Member
Hi,

It's not different from any other control. For example,
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet79. java
demonstrates dragging between two Labels. If you change its label1 to be a
Composite and comment out its setText(...) line then you have a Composite as
a drag source (the part about using a custom data type is not relevant to
your question).

HTH,
Grant


"SirWayne" <dennis.m@web.de> wrote in message
news:hkk7ek$980$1@build.eclipse.org...
> Hello,
>
> how can i use a hole composite as a DragSource?
>
> Composite composite;
> DragSource dragSource = new DragSource(composite, DND.DROP_DEFAULT |
DND.DROP_MOVE | DND.DROP_COPY);
> Transfer[] transfers = new Transfer[] {new MyTransfer()};
> dragSource.setTransfer(transfers);
> dragSource.addDragListener(new DragSourceAdapter() {
>
> @Override
> public void dragStart(DragSourceEvent event) {
>
> System.out.println("start");
> }
>
> @Override
> public void dragSetData(DragSourceEvent event) {
> System.out.println("setData");
> }
> });
>
>
>
Re: DragSource and Composite [message #513252 is a reply to message #512707] Tue, 09 February 2010 09:19 Go to previous messageGo to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Ah okay thanks my Problem was, that the Composite was covered by the other widgets.
Re: DragSource and Composite [message #513268 is a reply to message #513252] Tue, 09 February 2010 05:20 Go to previous messageGo to next message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
Registered: July 2009
Senior Member
If you want dragging any child of a Composite to initiate a drag then you
need to create a DragSource for each child. There isn't a way to make one
just for the Composite that will automatically work for its children as
well.

Grant


"SirWayne" <dennis.m@web.de> wrote in message
news:hkrqu9$3jj$1@build.eclipse.org...
> Ah okay thanks my Problem was, that the Composite was covered by the other
widgets.
Re: DragSource and Composite [message #513472 is a reply to message #513268] Wed, 10 February 2010 05:43 Go to previous message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
[quote title=Grant Gayed wrote on Tue, 09 February 2010 05:20]If you want dragging any child of a Composite to initiate a drag then you
need to create a DragSource for each child. There isn't a way to make one
just for the Composite that will automatically work for its children as
well.

Grant
/quote]

Ok thanks good to know. I thought it works for the deepest control too.
Previous Topic:How to control the Tab selection
Next Topic:Set focus problem in editor
Goto Forum:
  


Current Time: Wed Jul 23 09:49:04 EDT 2014

Powered by FUDForum. Page generated in 0.01671 seconds