Skip to main content


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 17:04 Go to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
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 17:12]

Report message to a moderator

Re: DragSource and Composite [message #513033 is a reply to message #512707] Mon, 08 February 2010 15:32 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
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 14:19 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
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 10:20 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
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 10:43 Go to previous message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
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: Mon Dec 09 10:33:24 GMT 2024

Powered by FUDForum. Page generated in 0.03634 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top