fyne icon indicating copy to clipboard operation
fyne copied to clipboard

Add drag and drop support

Open andydotxyz opened this issue 5 years ago • 26 comments

Add the events for these gestures.

Explore further what's required to integrate with system DnD

andydotxyz avatar Mar 04 '19 00:03 andydotxyz

it would be useful to allow it or not programmatically.

boussou avatar Mar 24 '19 10:03 boussou

Can you expand on that thought? Do you mean that widgets should have an API for controlling if DnD is enabled? Do you mean for creating custom widgets or for buitlin ones?

andydotxyz avatar Mar 24 '19 13:03 andydotxyz

Sure. I would like to be able to decide if/when to allow clipboard & drag and drop. I mean it could be important for security reasons for example. I think having that kind of setting available "framework wide" & set at startup would be sufficient.

boussou avatar Mar 24 '19 21:03 boussou

Would this (http://anton.maurovic.com/posts/win32-api-approach-to-windows-drag-and-drop/) help with the Windows side of this ?

rausm avatar Aug 22 '19 11:08 rausm

Possibly relates to URI registry? How do we handle unknown or custom defined types etc

andydotxyz avatar Dec 11 '20 16:12 andydotxyz

This needs some thought and planning on how to approach.

andydotxyz avatar Dec 11 '20 16:12 andydotxyz

it`s work now?

user1121114685 avatar Feb 09 '21 15:02 user1121114685

it`s work now?

This has not been completed. The work has been moved out to the release after the one we are working on now.

andydotxyz avatar Feb 09 '21 22:02 andydotxyz

it`s work now?

This has not been completed. The work has been moved out to the release after the one we are working on now.

Very much looking forward to

user1121114685 avatar Feb 10 '21 08:02 user1121114685

it`s work now?

This has not been completed. The work has been moved out to the release after the one we are working on now.

Look forward to drag and drop

PresleyHank avatar Feb 16 '21 12:02 PresleyHank

Look forward to drag and drop

arlin-github avatar Mar 08 '21 08:03 arlin-github

When will it be finished?

arlin-github avatar Mar 08 '21 08:03 arlin-github

This does not have a completion date. It is temtatively placed in the release /after/ the one we are working on. This would suggest late 2021 - but nothing is committed yet.

andydotxyz avatar Mar 08 '21 09:03 andydotxyz

Please find an idea how java's SWT (close to C) toolkit implemented Drag and Drop in Mac, GTK, Windows API:

https://github.com/eclipse/eclipse.platform.swt/tree/master/bundles/org.eclipse.swt/Eclipse%20SWT%20Drag%20and%20Drop

dtrehas avatar May 20 '21 07:05 dtrehas

Please find an idea how java's SWT (close to C) toolkit implemented Drag and Drop in Mac, GTK, Windows API:

https://github.com/eclipse/eclipse.platform.swt/tree/master/bundles/org.eclipse.swt/Eclipse%20SWT%20Drag%20and%20Drop

Also the native part (C,C++) of java SWT https://github.com/eclipse/eclipse.platform.swt/tree/master/bundles/org.eclipse.swt/Eclipse%20SWT%20PI

In older versions they had also code for 32-bit implementations

dtrehas avatar May 20 '21 07:05 dtrehas

Thanks for the links, However I don't think SWT is Java's main API - Swing or JavaFX are their main UI libraries...

andydotxyz avatar May 24 '21 09:05 andydotxyz

True, SWT has a more C-like API, maybe easier for porting to Go.

Thank you for your wonderful work!

dtrehas avatar May 27 '21 04:05 dtrehas

it`s work now?

This has not been completed. The work has been moved out to the release after the one we are working on now.

Look forward to drag and drop

I am agree

ddkwork avatar Jun 22 '21 01:06 ddkwork

I want to ask, is this function completed now?

Xzhiming avatar Jul 27 '21 02:07 Xzhiming

I want to ask, is this function completed now?

No. If it was complete you would see this issue closed. There is now a proposal being pulled together for the API design https://github.com/fyne-io/proposals/pull/5

andydotxyz avatar Jul 27 '21 07:07 andydotxyz

it`s work now?

CrazyXi avatar Jan 15 '22 03:01 CrazyXi

it`s work now?

Please avoid this type of comment. It’s getting very repetitive. You have the exact same question answered in the comment above. https://github.com/fyne-io/fyne/issues/142#issuecomment-887282008

Jacalz avatar Jan 15 '22 08:01 Jacalz

Meanwhile this is a work in progress I've found a hacky workaround to get basic drag and drop support. It consists on modifying a single file by adding:

	RunOnDraw(f func())

to the file window.go at the end of the Window interface. Then after everything has been created and right before window.ShowAndRun add this block of code:

window.RunOnDraw(func() {
	glfw.GetCurrentContext().SetDropCallback(func(w *glfw.Window, names []string) {
		// here goes you onDropFiles code
	})
})

This is basic drag and drop support, meaning it doesn't inform you where the files are dropped, and if it was dropped on certain objects. (That functionality has to be implemented manually, although it is not too hard) Note: I would discourage this solution for any relatively big project, it would be much better to wait until this feature gets implemented correctly (which is scheduled for mid/late 2023)

Wartori54 avatar Jan 20 '23 16:01 Wartori54

Thanks for the hint. As you will have noticed from adding that code it is not technically challenging. The reason this is not yet complete is because defining the API is where the complex challenge lies.

andydotxyz avatar Jan 21 '23 18:01 andydotxyz

Dropping a file in to a fyne app and detecting it would be dope

chrisbward avatar Feb 02 '23 04:02 chrisbward

The dropping to window is a great start - but we need a full drag and drop API so items can source and receive items being dragged. This is a complex issue and will need to support multiple mime or some content negotiation. Plus some indication of the drag happening once initiated (i.e. attaching preview/name).

$500 is currently allocated for eligible contributors completing this work (see Contributing: Membership).

andydotxyz avatar Feb 08 '24 14:02 andydotxyz