LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple selection in a tree without using CTRL or Shift key

Hello all!

I'm trying to use a tree to display all the .png files I have starting  in a certain  folder.

My listing is doing fine what I want, but I need to select multiple files at once from that list and that must be done without using the keyboard.

By other words I'd like to select multiple tree items, as I would do if I was pressing the CTRL key, without using the keyboard (sorry if I'm being redundant.. 😉 )

The vi's I'm using to display the tree are attached. To use them, create a folder named "teste" in your C:\ drive and put inside it some other folders and .png files (as my program will only list .png files).

I already tried to use a program that simulates key pressing, but I'm not having success with the CTRL one 😞

Any help would be greatly appreciated!

Thanks in advance!
Download All
0 Kudos
Message 1 of 16
(4,973 Views)
There are a couple of ways you can do this...the easiest would be to use the Value Change event to detect that a new tag was selected, but use a shift register on the while loop containing an array of strings that are all the tags that have been selected.  Then, when the Value Change event fires, just add the new tag to the array, then set this array as the value of the tree control using a local variable in the Value Change event case.  A more elegant way might be to use the Mouse Down filter event and change the values yourself, but you can start with the method I described.
 
Good luck,
-D
Message 2 of 16
(4,949 Views)

And just in case you do want to go with your original method, I have done this in the past with a listbox, where you can't control the selected items. The key is to use the Mouse Enter and Mouse Leave events to trigger the key on and off.

This is the VI I used then, because it's what I had floating around, but basically, almost every Windows VI to do this would look basically the same.


___________________
Try to take over the world!
Message 3 of 16
(4,926 Views)
Hello!

I tried what Darren suggested and I'm creating the array with the selected tags, but I didn't quite understood how to "give the indication" to the tree of which tags should be highlighted.

I'm not understanding when you say: "...then set this array as the value of the tree control using a local variable in the Value Change event case". I should use a local variable of which object?

To deselect a certain tag that was already selected, by clicking on it again, is the process similar? Should I search in the array for the selected tag and if it exists I should remove it and then "refresh" the displayed tree?

Thanks in advance!

Sorry for this (perhaps) basic questions, but I've never used event structures and this type of programming tools.
0 Kudos
Message 4 of 16
(4,916 Views)
Finally I got it!

I think I achieved a aceptable result.

I can select and deselect whatever I want 😉

I'm just having a little problem with deselecting. I can't deselect all of my items. When I have only one tag selected and click on it to deselect it, it remains selected. I think it has to do with the "delete from array" procedure.

I'll try to discover my error.

Anyway my vi's at the moment are posted below...

Message Edited by Goju-Ryu on 10-03-2006 09:52 AM

Download All
0 Kudos
Message 5 of 16
(4,912 Views)

You need to change the selection mode of your tree from "1 or more items" to "0 or more items".  To do this, right-click the tree control and choose "Selection Mode > 0 or More Items".

-D

Message 6 of 16
(4,901 Views)
About not being able to deselect all the items I spotted a thing that confused me...

When I only have one tag selected in the tree and I click on it in order to deselect it, in the event structure the value property doesn't indicate the tag I clicked 😞
Any help on this? It's because of this I can't deselect all of the items...

I already changed the "selection mode" to "0 or more".
0 Kudos
Message 7 of 16
(4,901 Views)

I don't think you will get a Value Change event if you click a tag that's already selected.  You may need to employ the Mouse Down event for that case.

-D

Message 8 of 16
(4,898 Views)
But I do get a Value change event when I click in a tag that is already selected, and that's how I know which one i have to deselect... But when I only have one tag selected, I can't deselect it because I don't get the Value change event... And I don't know why!

Please have a look at the vi's I last posted and try to give me a hand...

Message Edited by Goju-Ryu on 10-03-2006 10:33 AM

0 Kudos
Message 9 of 16
(4,897 Views)

What I said is correct...when you only have one object selected in the tree, and you try clicking that object, you will not get a value change event. You can check out the attached VI to verify this (it does the same thing your VI does, but it's a lot simpler).  If you want to support having the user click the final item to deselect it (thus leaving zero items), you will need to take the Mouse Down approach.

Good luck,
-D

 

Message 10 of 16
(4,890 Views)