How to do a "drag'n'drop" (from a file on my computer to a GUI) ?

35 views (last 30 days)
Hi,
I need to create a drag and drop to put it on the graphic interface of a program created in Matlab but I didn't find out how. The drag and drop must be from a wav file located on my computer to the GUI to be then reused through the program.
Any help would be appreciated :)
Thank you in advance for your answers

Accepted Answer

Geoff Hayes
Geoff Hayes on 10 Apr 2016
Eugy - I don't think that there is a way to drag and drop a file from your workstation onto a open MATLAB GUI. (Though this would be a neat activity.) An alternative is to prompt the user to choose a file. See uigetfile for details.

More Answers (3)

Image Analyst
Image Analyst on 10 Apr 2016
Eugy: I don't know if that's possible with GUIDE, but I believe GUIDE is too primitive. You might be able to do it with App Designer (GUIDE's replacement) but I haven't had a chance to check it out yet.
Otherwise, if it's even possible, your only chance is Yair http://undocumentedmatlab.com/?s=drag+and+drop. Good luck.

Walter Roberson
Walter Roberson on 12 Apr 2016
  1 Comment
Eugy
Eugy on 17 Apr 2016
Thank you for you answer
Using the drag'n'drop program found under your link, I could'nt drag in the window the txt file as specidified in the tutorial. I didn't find out the source of the problem (I am a new to GUI), maybe my MatlabVersion (2014) or something with ActiveX.
There were the following instructions:
% Type DragDropTest from the command line to test. Once the figure is % running try dragging a text file into either of 2 areas on the figure. % The upper portion will just populate a listbox with the names of files % that have been dragged into the bar above it. The lower box displays the % contents of any text file dragged into it. The bottom box also allows % text to be dragged from a text editor such as wordpad.
The error I got was:
Error using actxcontrol (line 184) Control creation failed. Invalid ProgID 'RICHTEXT.RichtextCtrl.1'.
Error in DragDropTest (line 36) h1 = actxcontrol(ProgID, [pos(3)*.1 355 pos(3)*.8 20],f,{'OLEDragDrop',@ShowFileNameOnDrop});

Sign in to comment.


Eugy
Eugy on 12 Apr 2016
Hi Geoff Hayes and Image Analyst, Thank you for your answers :) I went through undocumentedmatlab and I didn't find on it what I was looking for so I used the uigetfile instead of the drag'n'drop, it works fine. Still I keep this website on my Bookmarks, could be a precious help for other tasks !
  2 Comments
Image Analyst
Image Analyst on 12 Apr 2016
An even better workaround is to use a list box to load up your data or image files. Why burden the user with the tedious uigetfile()?
Eugy
Eugy on 17 Apr 2016
Magic_gui seems interesting, I may certainely get inspired by it, thanks for sharing :)

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!