Tuesday, February 21, 2012

MATLAB GUI: implementing drag-and-drop

In the last tutorial, we went over the design of the drag-and-drop functionality of a uicontrol. In this tutorial, we will be implementing the functionality using the code from earlier tutorial. For your convenience, the drag_and_drop function is included in the zip file.

Procedures: 

1. Download mouse5.zip and ready the files in a working matlab directory.
2. Using GUIDE, set WindowButtonMotionFcn, WindowButtonDownFcn, and WindowButtonUpFcn property of the gui to null. You may remove their corresponding functions in the gui_mouse.m file.
3. Attach/register drag_and_drop function to WindowButtonMotionFcn property of the gui in the opening function of the gui.

set(hObject, 'WindowButtonMotionFcn', @drag_and_drop);

4. Save all files and execute the gui.

Video walk-through


Files
Download source code


2 comments: