07-08-2022 11:46 AM
I am trying to use the drag and drop features from multiple multicolumn list boxes.
I have tried doing this several ways.
1) A bit more involved and I used the example from NI. I utilized a case structure to enable/disable the MCL and then an event structure for start dragging/drag enter/drop. This did not work. I was still able to drag/drop to a disabled MCL.
2) I tried to enable dynamic events and register the events of each MCL while disabling others. This did not work and still allowed me to drag to a disabled MCL.
3) I attempted to break apart the start dragging/drag enter/drop of the two MCL where I am dropping data into two separate event structures. This caused problems because all events were waiting for one another to finish. So, I put one event structure on one side of a case structure and the second on the other case. This did not work either.
4) I tried just a bare bones while loop enabling the drag/drop features for each list box. I then disabled & greyed one of them out but I am still able to drag to the disabled and greyed MCL.
Is there something simple that I am missing here? I am attaching a block of code (LV 2019) of a simplified version of the concept. It contains a sample version of the first way I tried and the fourth scenario. It is an NFL player example of just dragging a player from the main MCL to a second and third MCL.
All I am trying to do is enable 1 or more MCLs to be dragged/dropped to while disabling 1 or more MCLs so that they cannot be dragged/dropped to.
Thank you!
Solved! Go to Solution.
07-08-2022 01:40 PM
Attaching a simple drag/drop from 1 main list to 2 other MCL. For some reason, the bare bones code section in my original post did not work at all.
07-08-2022 02:23 PM
A little bit of playing around and I got it to work as expected...
Good luck!
07-08-2022 02:56 PM
Wow Frozen! That is....a mind shift for sure. Great job!.
Looking at this, I need to adjust two properties simultaneously (allow dropping & disable). I will see if I can enable this through different versions of my original code (with/without multiple event structures and dynamic events).
Right now I have 14 droppable MCLs. 1 dragging MCL main list. Of those 14 droppable, I need to have enable or disable at different intervals.
I will go back through my original code and see if I can disable dropping and disable the MCL from certain MCLs simultaneously and get this to operate.
Thank you!! I have been working on this all week (sadly) and not able to come up with a solution. I tried dynamic event structures, youtube galore, inviting my keyboard to a bonfire, and other unmentionables!
07-11-2022 03:52 AM
This help item is pretty comprehensive:
Implementing Custom Drag-and-Drop Behavior - NI
It's also in the offline help, under Fundamentals, Building the Front Panel, How To, Dragging and Dropping in LabVIEW.
In my experience, once you handle one drag even, you need to implement all drag events, same for dropping.
07-11-2022 08:12 AM
Thank you wiebe@CARYA.
I have been through quite a bit of the documentation for drag/drop capabilities and my .vi does this without issue.
What I cannot seem to figure out is how to disable the drag/drop feature during certain times of execution.
The best analogy I can think of is dealing cards. If you have a deck of cards (drag list) and you issue out one card to each player (drop).
However, you have a particular sequence in which cards are dealt. It always starts at Player #1. Also, you do not want to drop cards to Player #1 four consecutive times before dropping one card to Player #2.
I am trying to sequence which MCL on my front panel is capable of accepting while other MCLs are disabled. Unfortunately, the disable property does not seem to function like disable does for other indicators/controls. I can disable the individual MCLs. They will grey out and disable in the sequence I have dictated. But, I can still drop to them in any order even when they are disabled. I can always tell the end user to not drop data into an MCL that is greyed out but we all know how that will work out.
07-11-2022 08:38 AM
@BrianK75 wrote:
Thank you wiebe@CARYA.
I have been through quite a bit of the documentation for drag/drop capabilities and my .vi does this without issue.
What I cannot seem to figure out is how to disable the drag/drop feature during certain times of execution.
The best analogy I can think of is dealing cards. If you have a deck of cards (drag list) and you issue out one card to each player (drop).
However, you have a particular sequence in which cards are dealt. It always starts at Player #1. Also, you do not want to drop cards to Player #1 four consecutive times before dropping one card to Player #2.
I am trying to sequence which MCL on my front panel is capable of accepting while other MCLs are disabled. Unfortunately, the disable property does not seem to function like disable does for other indicators/controls. I can disable the individual MCLs. They will grey out and disable in the sequence I have dictated. But, I can still drop to them in any order even when they are disabled. I can always tell the end user to not drop data into an MCL that is greyed out but we all know how that will work out.
BTW, Frozen's solution seem to work just fine. If it's not working, post an update.
If you are trying events to get more control (to allow dropping at intervals?), post what you've tried with events.
07-11-2022 12:21 PM
I was able to get the MCLs to cycle with Frozen's suggestion 😁. I was having an issue with the names populating into the drop MCLs in DragDrop_NFL(V3).vi.
This was fixed in DragDrop_NFL(V4).vi after adding some drag starting & drag enter events into the event structure.
I am still confused as to why a change value event is needed for the disabling of a control in order to cycle through the MCLs. I am having to establish a condition during initialization, change the condition in a case structure, recognize and accept the changing of condition in an event structure in order to just a change condition. This seems like an overkill.
One would figure that changing a property node to "disable" should disable the control/indicator/list/table. This was done at the beginning within the case structure. This should inherently disable most (if not all) functionality until it is enabled again. In addition to disable, forcing the control/indicator to False for AllowDropping....sure, I can even understand this if disable is not capable of shutting down all capabilities. But bouncing back and forth between case to event structures is not very intuitive in my opinion.
There has to be a simpler way to do this. I have spent a week and a half trying to figure out how to cycle through MCLs and have unfortunately ran short on time with this project. It wasn't all time lost as I was able to play around with dynamic events. I did not successfully get one to work in my application but it broadened my knowledge base. In an attempt to get this to work, I also tried running multiple event structures in separate parts of the code. I quickly realized this was going to be a headache. I now have some hanger queen coding that I can cannibalize into other projects at a later date.
07-11-2022 01:12 PM
The Value Change event isn't what's disabling the dropping, it's writing the property node. Frozen's code just used an event structure to trigger the Disable code. You can put that property node anywhere you'd like.
The thing is, you don't actually need the AllowDropping property. If you look at the Help for that property (hit Ctrl + H and mouseover it), that only works for the automatic item handling code. (I think you could actually use that here, but you've implemented your own item names which is fine).
Since you're not using the automatic drag/drop handling, you have to explicitly handle your Drag Enter event, which fires when you try to drag the item into the box. If you set "Accepted?" to True, you'll be able to drop it there. You've got Accepted always set to True so you can always drop things there. You need to check for whether the control is enabled or not before you tell it to Accept the drag beginning.
(Alternatively, you could check for Disabled at the beginning of the Drop event, but this way lets your user know "Hey, you can't drop here.").
You also had some extra code that wasn't helping things. You only need one While loop here, none of the Enable booleans, and none of the AllowDropping property nodes. You just need to change your Drag Enter to this:
Try the attached version. Your code could use a little more tidying up but it's not too bad. Also, going forward I'd recommend putting the enable/disable into a subVI that uses a Control refnum as an input. You could then define a "master list" that automatically disables one thing and enables the next one. This should be a clearer way for you to understand what's going on though.d
07-11-2022 06:42 PM
Thank you BertMcMahan!
That is a great explanation. I thank you very much. I actually do have some conditional aspects in my code and for the acceptance of the drop. It does ask the user if they want to drop this data into this MCL. Just like a lot of people in the forum, I have to be careful what I post due to company/proprietary issues. But, I tried to give a general overview of what I was trying to do. Which also makes it hard for the experts like yourself to come up with solutions..
I am going to look into your suggestion of how Frozen wrote the code to disable. I used it to make my code work for the time being but I am certain I am missing a concept somewhere. I want to learn why because I actually enjoy LabVIEW and like efficiency. I always want to make things better.
I am not a developer or architect by any means. I attended 2 basic LV courses back in 2006. From there, I have been on my own to teach myself. I have done fairly well over the years to make things work. I have been able to write data acquisition and control systems. But, I also know that there are many concepts and programming skills that do not register with me sometimes. I try pretty hard not to ask the forum questions for things I should be able to logically figure out with posts and youtube. I try to do my due diligence in learning/researching before asking. After a week+, I hit a point of frustration and need to progress in some manner as it is not my money that is paying me to play with programming. Companies and customers expect progress. I learn as fast as I can. I sincerely appreciate yours and Frozen's help!
Thank you!