LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

RunPopupMenu

Is there any way to overide "RunPopupMenu" by pressing keys?
I am implementing a "auto-complete" feature where user types commands in the textbox, and I display "RunPopupMenu" to suggest possible commands that are parsed so far.
For example, if the user wants to type "SCANConnect" and let say there are several similar commands. Then, as user types upto like "SC" then I show 3 or 4 possible commands that could start with "SC".
Then, user should have two options: either select one of the commands shown by "runPopupMenu" OR just keep typing letters(in this case, the "RunPopupMenu" should automatically disappear, and it is the trouble i am having). 
 
Once "RunPopupMenu" is up, it would never go away unless i select one of the menus.
 
Is there any way that I can kill this "RunPopupMenu" if I choose to just keep typing?
 
Thanks,
 
JL
0 Kudos
Message 1 of 6
(3,698 Views)
Hello!

Interesting application!  Unfortunately I do not believe that it is possible to track events through the popup menu except for the event commits that are a result of actually selecting an item.  I think your best bet to proceed would be to create a very small panel containing a listbox control which you could populate with the possible items for the user.  When the user is typing and you would like to display the listbox you could call a function which displayed the panel in the appropriate size/location, populated the listbox.  Then if the user selects an item on the listbox you can catch that event, and if the user continues to type without selecting one of the items you could just discard the panel with the listbox.

Let me know how things go, or if you (or other community members) come up with any other ideas!


Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 6
(3,669 Views)
Travis, your solution would probably work if the user was to click on a selection with a mouse, but if I'm typing and want to select an auto-completion choice, I normally use the down arrow key to highlight my choice and press enter.  With the separate panel containing the list of completions, it would not be able to respond to the down arrow key presses. 

I suppose you could handle the key presses in the main panel and programmatically highlight the next selection in the child panel, then pass the highlighted value back to the main panel and replace the text in the text box.
----
I am the founder of CnCSoftwareSolutions. When not cleaning up baby drool, I write about test data or work on Vision, a tool for understanding your test data. Visit me at www.cncsoftwaresolutions.com
0 Kudos
Message 3 of 6
(3,663 Views)

Hello,

I belive that you can still monitor the text in the main panel, when you match the first couple letters that you would want to have a popup for you can programmatically load the sub-panel containing the listbox.  Once this is called the sub panel should be active allowing it to respond do the arrow keys.

            GetRelativeMouseState (panelHandle, 0, &x, &y, 0, 0,0);
           

            if ((listboxPanel = LoadPanel (0, "menu.uir", LSTBXPNL)) < 0)
                return -1;
            DisplayPanel (listboxPanel);
           
            SetPanelAttribute (listboxPanel, ATTR_LEFT, x);
            SetPanelAttribute (listboxPanel, ATTR_TOP, y);

When I execute this code snippet the sub panel displays at the current mouse location and the listbox is actively responding to the arrow keys.

Let me know if this works out, I am still interested in finding a way to do this!



Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 4 of 6
(3,638 Views)
Yes, the arrow keys work for navigating the list, but the focus is now on the sub panel so you can't continue to type in the main panel.  It would be better to use a floating subpanel and keep the focus on the main panel. 
----
I am the founder of CnCSoftwareSolutions. When not cleaning up baby drool, I write about test data or work on Vision, a tool for understanding your test data. Visit me at www.cncsoftwaresolutions.com
0 Kudos
Message 5 of 6
(3,631 Views)
Hello JL,
 
What you're attempting is very similar in behavior to the pathctrl custom control shipped with CVI.  We ship the source code along with the compiled objects and function panels so that users like yourself can make edits to the behavior or implement similar controls.  I would suggest taking a look at [CVI dir]\toolslib\custctrl\pathctrl.c.  Specifically, there is a PopulateListBox function in that file, which if you re-implement to list possible command completions, may provide just the right behavior you're looking for.
 
If you try this, make sure you start with a fresh copy of the pathctrl instrument, so that the original pathctrl still works as usual.
 
Hope this helps.
 
Mert A.
National Instruments
0 Kudos
Message 6 of 6
(3,627 Views)