LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the default control on a panel

Is there a control attribute to force a control (e.g. a button) to be treated as the default control on a panel (I don't speak about system popups)?

I had the issue with a panel having three buttons (besides other controls) where I assigned the ENTER key, the DownArrow key and the ESC key to the buttons. When running the tool, a ENTER should let the tool continue, the DownArrow should skip a function and the ESC should terminate execution. I used GetUserEvent() to run this functionality checking the control that caused the event. When hitting the ENTER key, my tool code always executed the skip function altough it was meant to be used for the 1st button.

I found out that this is due to the fact that the skip button has been created by me as last button, hence the continue button has been created before.

As I found no possibility in the control properties to change the default button, my workaround was to delete the continue button and recreate it. Then it became the default button.

But I wonder if there is another possibility to force a button becoming the default one?

 

Thanx and Regards

Manfred

0 Kudos
Message 1 of 4
(1,267 Views)

Down arrow and Esc keys can be assigned to buttons as shortcut keys:

Screenshot 2021-06-03 09.28.40.png

 

Different is the case for the Enter key, which is handled by Windows before sending it to the CVI program: the Enter key fires the commit event on the active button, and as you already have found the order of controls on the panel determines which is the active control when the panel is displayed (unless you issue a SetActiveCtrl command before).

The problem is that if the user tabs between controls, he can fire events with the Enter key on all buttons on your panel.

To furthermore complicate things, the Space key acts the very same way on command buttons (i.e. pressing the space bar will fire the commit event if the active control is a command button).

For this reason, even if you could try to intercept windows events or CVI keypresses, I discourage you to try altering Windows mechanisms since there is lot more in the OS than the user normally knows and you are very likely to ignore some Windows feature that the user will surely bump into at any arbitrary moment in the future (according to the Murphy's Law, if you know what I'm speaking of 😉 )



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(1,214 Views)

I forgot to say that you can alter the order of controls in a panel by pressing Ctrl-T while in the UIR editor: the Edit Tabbing Order function will permit you to determine in which order controls are activated while pressing the Tab key.

 

Look at this picture: white numbers show the order active at this  moment, you can alter it by clicking on controls and changing the numbers in black. The control with index 0 will be the active control when the panel is shown.

Screenshot 2021-06-03 09.45.04.png

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 4
(1,210 Views)

Hi Roberto,

 

thanx for your feedback. Your proposal I did already apply prior to my support request, but it seems that assigning the ENTER button to a different button than the default one (hence the selected one when the panel is loaded) has no effect. When the user presses the ENTER key, always the selected panel button gets the commit event.

This you can easily reproduce if you create a panel with at least two buttons where you assign the ENTER key to the button you created first and assign any other key to the button your created last.

When you run the panel, you will see not the 1st button catching the event but the last one.

 

Btw, I'm using CVI2019 (I also have CVI2020, but did not yet converted my projects).

 

Regards

Manfred

 

P.S.: I saw that you modified your response in the meantime....

I know this feature with the tab control:ScreenShot299.jpg

But as you can see here, the (former) default button ("Skip") even has a higher tab number than the Continue button.

But the hint with the "SetActiveCtrl" seems to be the interesting one.

Concerning WindowsOS, of course we cannot look into the crystal ball, we never know which gimmicks the MS programmers will implement in the future....

0 Kudos
Message 4 of 4
(1,209 Views)