LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Darren's Weekly Nugget 04/27/2009

Have you ever wanted to implement an auto-complete string in your LabVIEW UI?  I did this for Quick Drop in LabVIEW 8.6, and it's really easy:

 

 

That string control in the Quick Drop UI isn't really a string, it's a combo box control with the side arrow hidden via the Control Editor.   When Quick Drop launches, I populate the Strings[] property of the Combo Box with all possible palette object names.  As you type an object name, I'm simply taking advantage of the built-in auto complete that combo boxes already have.  I had to write a little extra code to handle the case when the user presses the up or down arrow while typing in the combo box.  Normally this will expand the combo box drop-down list.  Since I don't want Quick Drop users to ever interact with the combo box drop-down list, I discard the arrow key press and instead, give focus to the listbox below the string.

Message Edited by Darren on 04-27-2009 11:48 AM
Message 1 of 15
(10,999 Views)

Would be nice to have that code fragment for download, although it's not difficult to do on ones own.

 

Felix 

0 Kudos
Message 2 of 15
(10,975 Views)

Could you give some pointers as to how to hide the drop down in the control editor? I have tried a couple of things but failled to get a nice solution - I always end up with a grey semi transparent square... see attached pic.

Autocomplete attempt

In addition to the method described in the pic I also tried filling the button with the transparent color and the mysterious square remained!

 

Thanks,

Shaun

Message Edited by shew82 on 04-27-2009 01:59 PM
Message 3 of 15
(10,942 Views)

Is there any chance, as part of this thread, or as part of a future nugget, we can get the secret to how you pulled off the bottom part of the Quick Drop dialog?  I'd like to know how to present a filtered list as someone types.  There is a second control, right?  It's not all a combo box?

 

By the way, thanks for presenting this nugget!  I have been wondering how to do this for quite some time.

 

Oh, yeah, I concur with Felix's statement above.

Message Edited by InternationAL on 04-27-2009 02:36 PM
0 Kudos
Message 4 of 15
(10,903 Views)

To customize the combo box, you can color the area transparent, then move it to the back and resize it to (1,1) using the alignment menus and hide it behind the control. You can also find an example showing autocomplete in a string in the first post of the thread linked to in the next paragraph.

 

As for the search, I created my own version of QD a while back, which shows how to do this. You can find it here. The code isn't the cleanest, but the search part is well contained within a single VI.


___________________
Try to take over the world!
Message 5 of 15
(10,889 Views)

Thanks tst! 🙂

 

It seems I was having a bit of a brain fail this morning - I forgot about that little guy!

 

Shaun

0 Kudos
Message 6 of 15
(10,880 Views)

I have attached a VI to this post (saved in 8.6) that contains a copy of the combo box from Quick Drop.  It has the side arrow hidden, which, as tst explained, can be accomplished by resizing it to 1 pixel, and hiding it behind the control.  You'll also notice that my combo box is surrounded by a black border decoration.  I did this to give it as much of a dialog appearance as I could, since I had to start with a simple combo box (from the Classic controls subpalette) to be able to customize it the way I wanted in the control editor.

 

To answer InternationAL's question, the area under the Quick Drop text box is a listbox. As you type in the text box, I am doing a search of all the palette object names for anything that matches what is typed (this is triggered by the key down and timeout cases of an Event Structure).  Once the match search is complete, I repopulate the listbox with the names of anything that matched.

0 Kudos
Message 7 of 15
(10,859 Views)

Don't you have to turn on the "Update value while typing" for the combo box, or else the filtering of the listbox won't occur with the value currently displayed?  But, if you turn that on, the autocomplete turns off.  How do you get both autocomplete and "Update value while typing" to be on at the same time?  On my end, I seem to be able to get only one or the other.

 

Plus, what's the search function being used?  I like how in Quick Drop, you can search for two different string chunks, like "rect" and "pola", if you type in "rect pola", and you'll find, for example, the "Rectangular to Polar" and "Polar to Rectangular" functions.  I am currently using the "Match Pattern" LabVIEW primitive.  Should I be using a different one, or is the Quick Drop search a little more complicated than can be implemented with a single LabVIEW function?

 

Thanks for a great weekly nugget!

Message 8 of 15
(10,775 Views)

InternationAL wrote: 

...or is the Quick Drop search a little more complicated than can be implemented with a single LabVIEW function?


It's more complicated. See the link in my previous post for an example implementing something similar.


___________________
Try to take over the world!
0 Kudos
Message 9 of 15
(10,749 Views)
Hmm... any chance of a conversion to LabVIEW 6.1 compatibility?


Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 10 of 15
(10,740 Views)