Skip to content

xiangruili/uiFileDnD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drag and Drop OS file/folder(s) into Matlab figure/uifigure (2026.03.05)

View uiFileDnD on File Exchange

The uiFileDnD implementation allows to set up a callback fired when files and/or folders are dropped onto a (ui)figure component.

In the callback, full file/folder names are captured for user to decide the action. dropXY, Ctrl and Shift key status during the drop event are also reported.

Example to drop file/folder onto uilistbox of uifigure:

obj = uilistbox(uifigure, 'Position', [80 100 400 100]);
uiFileDnD(obj, @(o,dat)set(o,'Items',dat.names));

Example to drop file/folder onto listbox of figure:

obj = uicontrol(figure, 'Style', 'listbox', 'Position', [80 100 400 100]);
uiFileDnD(obj, @(o,dat)set(o,'String',dat.names));

Note:

  1. File DnD onto uifigure works since Matlab R2020b (since R2025a for Linux).

  2. The following line needs to be added into startup.m file for R2025a and likely later:

    try addprop(groot, 'ForceIndependentlyHostedFigures'); catch, end

  3. java_dnd.m & MLDropTarget.class are for figure() before R2025a, and can be removed in the future.

About

Enable file DnD onto Matlab uifigure

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages