Reorderable Listbox

版本 1.9.0.0 (38.9 KB) 作者: Erik Koopmans
Creates a listbox whose contents can be reordered by clicking and dragging items.
1.2K 次下载
更新时间 2012/7/31

查看许可证

Creates a listbox whose contents can be reordered by clicking and dragging items. The resulting listbox can be fully customized using standard GET and SET methods.

The listbox created is a standard Matlab UICONTROL('Style','Listbox'), whose underlying Java JList has the following properties modified: 'DragEnabled', 'DragSelectionEnabled', 'DropMode', 'DropTarget', 'MousePressedCallback', and 'MouseReleasedCallback'.

The user may specify their own 'MousePressedCallback' (JList), 'MouseReleasedCallback' (JList), 'DragOverCallback' (DropTarget), and 'DropCallback' (DropTarget) in the list of input property/value pairs. These callbacks will be called at the end of the REORDERABLELISTBOX default callbacks, with two inputs, HANDLE and EVENTDATA. The 'DragOverCallback' is given a third input, PERMORDER, which indicates how the list has been reordered, i.e. STRING = STRING(PERMORDER). This can be used to reorder any underlying data that the list may represent.

To reorder items, REORDERABLELISTBOX creates a drag-and-drop object tied to the listbox. An unintended result is that list items can be dragged off of the list and dropped onto other components. Items can also be dragged from other objects onto the list; dropping onto the list has no effect.

If the listbox displays erratic redraw behaviour when being reordered rapidly (single cells being drawn too tall or too wide), you may need to explicitly set the 'FixedCellHeight' and 'FixedCellWidth' properties of JLISTBOX (values of -1 tell Java to automatically determine cell size, but may lead to this erratic behaviour).

This utility makes use of the freely available FINDJOBJ, written by Yair Altman and available on the Matlab File Exchange:
http://www.mathworks.com/matlabcentral/fileexchange/14317

引用格式

Erik Koopmans (2024). Reorderable Listbox (https://www.mathworks.com/matlabcentral/fileexchange/37642-reorderable-listbox), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2010a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.9.0.0

1.1.1: Separated DropCallback from MouseReleasedCallback, for more user customization.

1.7.0.0

1.1.0: Added support for user-definable callbacks (MousePressed, MouseReleased, DragOver); added permOrder.

1.5.0.0

Modified description, documentation, and screenshot.

1.0.0.0