LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Ring control keyboard shortcut

Solved!
Go to solution

Hi all,

 

Is there a way to assign shortcut keys to each items in a ring control?  The ring control that I have currently has 40 items.  My intention is to have it as follows:

 

[1] Item1

[2] Item2

[3] Item3, etc...

 

So, once the ring control is active, user can type in "20" to select item #20.  

 

I tried EVENT_KEYPRESS, but as soon as the ring control pop-ups, I can no longer trap any key press events.

 

Thanks,

YL
0 Kudos
Message 1 of 4
(3,739 Views)
Solution
Accepted by topic author YL_2009

Hi YL,

 

The functionality is not available directly as you required.

But you can program this behaviour, even though it is a little harder than it seems.

 

I attached a sample project that -kind of- simulates this behavior.

 

In the project, there is a ring with some values listed.

Here, the key point is that, user should not click the ring but put focus on it using the TAB key. As you pointed out, once the list pops-up you cannot capture key press events.

You can also programmatically make it the active control if it is applicable to your application (use SetActiveControl).

 

After the ring is the active control (in my code it is active immediately after the program starts) just type 2-character number codes.

Another key point: you should complete the value to 2 digits. So, to select Item1 user has to press '0' and '1'.

 

There is also a time limit. You have to press the 2 digits within 0.5 seconds. Otherwise the second digit will be treated as the first digit of a new number code. You can improve the behaviour to add a timout timer so that you don't have to type 2 digits for number 1 to 9, but that may be too much effort unless it is too necessary.

 

After the 2 digits are typed quickly, you can see the typed number value on the numeric indicator.

The ring is modified only if the typed value is available in its list (1-5, 10, 15, 20, 25 are the default values I assigned).

 

The program is also prone to (ignores) non-numeric inputs.

So that I did not have to put error checking on the string-to-int conversion (atoi function).

 

That was fun to program, I hope you find it useful too.

Message Edited by ebalci on 11-20-2009 09:07 AM
S. Eren BALCI
IMESTEK
Message 2 of 4
(3,728 Views)

Hi Eren,

 

Thanks for your help.  

 

I modified a little bit of your code.  Now it also ignores virtual keys like TAB, ALT, etc...

 

I wanted users to be able to get to the ring control with short cut key F3.  The F3 key will pop-up a "fake" ring control for user to enter the 2-character number codes.  Once user selected the item, the actual ring control will get the selected list item and pop-up panel will close.

 

See the attached sample project for more information.

 

0 Kudos
Message 3 of 4
(3,700 Views)

Hello YL - 

 

It sounds like your'e set, but you might want to take a look at the hot ring control.  It's a built in custom control that allows for quick-typing while the selection menu is not showing.

 

NickB

National Instruments 

0 Kudos
Message 4 of 4
(3,694 Views)