LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dragging a divider OUT of ListBox

LV 2023, Win 11
I'm trying to implement a Trashcan behavior.

I have files with a list of items, some possibly blank.
I'm showing them in a Listbox  (The symbols are just showing as an index - won't show when done).

I want the user to be able to:
1... Rearrange the order of items.

2... Drag a blank line to the trash to delete it.
3... Drag a divider into the list to insert it.
4... Drag a divider OUT of the list to delete it.

image001.png

 

Listbox is set to ALLOW DRAGGING, ALLOW DROPPING and ALLOW DnD OUTSIDE OF CONTROL.

 

I have a DRAG ENTER event on the trashcan where it checks for a LV_LISTBOX_ITEM among the available data names and "opens" the trashcan (switches pictures) when it's OK. It also checks for blanks (don't want user to trash a valid item).
That works fine.

I have a DROP event on the trash - If the user drops on the trash, I remove the blank from the list, end update it.

That works fine.

I have a DRAG STARTING on the DIVIDER thingy - it packages a LV_LISTBOX_ITEMS item with a symbol of -1, which is the dividing line.  I can drag that to the list box and drop it where I want.  

That works fine.

 

But if I try to drag the divider line OUT of the listbox, I can't get it to work.  In DRAG ENTER I look for LV_LISTBOX_ITEMS in the AVAILABLE DATA NAMES and it finds it.
... as expected.
Then I GET DRAG DROP DATA with a type of LV_LISTBOX_ITEMS (array of cluster of array of strings | integer)
But what I get from that is the name of the CURRENTLY SELECTED ITEM, and its symbol.
For debugging the symbols are set to the index and that lets me see what's going on.

The LISTBOX selection mode is ONE ITEM.  If I set it to 0 or 1 ITEM, then I don't even get a DRAG ENTER on the trashcan when I drag a DIVIDER.

I think that means that the listbox SELECTION is not allowed to include a divider. So when I click on the DIVIDER and drag it out, the selection is not changed, and the control tells me it's dragging the selection.

Anything missing in my thinking?
Any ideas how to do this?
Or am I stuck with dragging blanks in and out?

P.S. if I replace the "-1" with "0" when dragging INTO the listbox, I get a blank line, and I can drag it OUT and trash it without issue. But that messes up using the SYMBOL as an index.  (I need to take the rearranged list and use it to rearrange a bigger list).

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 1 of 3
(135 Views)

To be clear, I want to use the SYMBOL property as an index.  If I start with items A, B, C ,D, E, I attach symbols of 0,1,2,3,4 to them.
If the user rearranges them to A,C,B,D,E, the symbols (which won't show) also rearrange into 0,2,1,3,4. That means I can rearrange the master file by using indexes 0,2,1,3,4.

If you insert a DIVIDER with index -1, I can easily use that to generate a dummy entry using indexes 0,2,1,-1,3,4

But if you insert a SPACE with index 0, then you end up with indexes 0,2,1,0,3,4, meaning we have a duplicate item.  Not good. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 3
(105 Views)

OK, I solved this a different way.  Instead of dragging a {Space | -1} item INTO the listbox, I now drag a {"---", 99999} item into it.

 

I check for "---" when trashing them (I don't want to delete a regular item) and the 99999 still works as an index to get a default (blank) item when re-saving.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 3
(74 Views)