Reorderable Listbox
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
Zitieren als
Erik Koopmans (2024). Reorderable Listbox (https://www.mathworks.com/matlabcentral/fileexchange/37642-reorderable-listbox), MATLAB Central File Exchange. Abgerufen.
Kompatibilität der MATLAB-Version
Plattform-Kompatibilität
Windows macOS LinuxKategorien
Tags
Quellenangaben
Inspiriert von: findjobj - find java handles of Matlab graphic objects
Inspiriert: Simulink Subsystem Port Organiser
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
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 |