LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

'Enter' quits app.

Solved!
Go to solution

Hi.

 

I have an application that has numerous contril buttons on the main panel.

One button is a 'Quit' button that exits the application.

Another is a text window that sends the contents of the window out a serial comm port (uses the VAL_ENTER_VKEY test).

 

When running an automated test all the controls are 'Dimmed' so that they are not operable. Only two control buttons are active one being the 'Quit' button.

The automated test sets various dimmed controls to different states via state machine code.

 

If the 'Enter' key is pressed during the automated test it quits the application just as if the 'Quit' key was pressed with the mouse.

 

I event went as far as seting the SetActiveCtrl (mainPanel, PANEL_MAIN_TX_STRING) to a control at the start of the test.

 

Does anyone have a fundamental explanation as to the operation of the 'Enter' key wrt the main panel (any panel for that matter) when it is not explicitly coded to do anything?

 

Thanks.

 

LabWindows V9.0.0.0

0 Kudos
Message 1 of 14
(4,619 Views)

The quit command button apparently has the focus at the time you're hitting the Enter key.  

 

Or maybe you've defined Enter as the shortcut key for the Quit control? 

 

Does the app quit when you hit the space bar?

 

Check the "close control" field of the panel edit window and see if you've inadvertantly defined some control other than the Quit button as the panel close control.

 

When the app first shows thepanel, what control has the focus?  (You can tell because the control will have a dashed outline on it that moves from control to control with the tab key).

 

Menchar

 

0 Kudos
Message 2 of 14
(4,616 Views)

Menchar: 

 

When this condition happens the 'Quit' button is NOT dashed. When I hit the Tab button repeatably then the 'Quit' button become active after the 4th press and then again after the 10th press.

 

The positions are 'Status', 'Abort', 'Quit', 'Power', ?,and ?. There are two that I cannot tell. I thing one is a list box that display comm activity and the other a label?

 

The rest are all dimmed.

 

When the app first starts I explicitly assign the focus to the Tx Data Window:  

SetActiveCtrl (panelHandle, PANEL_MAIN_TX_STRING);

 

The only place I define 'Enter' is the call back for the Tx text window using if (eventData1 == VAL_ENTER_VKEY)... This window is dimmed when this happens.

 

YES when I hit the space bar the app quits also!

 

Any ideas?

 

Thanks.

0 Kudos
Message 3 of 14
(4,614 Views)

Well, since both the space bar and the enter key cause the app to quit, I have to think that either the Quit control or some other control that's been designated as the panel's close control is receiving the event and causing the closure.

 

Do you have any shortcut keys defined for any of the controls?

 

In the panel edit window, what control is identified as the Close control?

 

Menchar

Message Edited by menchar on 04-06-2010 05:10 PM
0 Kudos
Message 4 of 14
(4,613 Views)
And just to check, are you using individual control callbacks or are you trying to handle all panel events with a main callback (are you using InstallMainCallback by any chance)  ?
0 Kudos
Message 5 of 14
(4,614 Views)

Do you have a QuitUserInterface call somewhere in a callback? 

 

Do you happen to have one in your text control callback that is receving the space bar and Enter key events?

 

 

0 Kudos
Message 6 of 14
(4,612 Views)

As usual, menchar has covered with his questions a wide area of common problems with panels and controls. I can only add some hints on this situation.


NI Nubie wrote:

The positions are 'Status', 'Abort', 'Quit', 'Power', ?,and ?. There are two that I cannot tell. I thing one is a list box that display comm activity and the other a label?


A label is an indicator control that cannot have focus while you switch between controls with TAB key. Since you are using the listbox only to display program activity, you should set it as indicator as well in the UIR editor so that is skipped when tabbing; the same applies to all controls that are not intended to receive operator activity.

 

You should investigate a little bit more on those two phantom controls. May you have lost controls moved outside the visible portion of the panel? 


NI Nubie wrote:

YES when I hit the space bar the app quits also!


 

On Windows the space bar is a valid way of operating on command buttons: it seems that the real focus of your application is not the string control. If you press any key other than enter and the space bar, does the text go to the string control?

 

Last item: can you show us the relevant part of the string control callback?



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 7 of 14
(4,591 Views)

Menchar and Roberto.

 

When this condition happens (auto mode) the Tx Data control window box is hidden and not accessible by the user.

There are no short cut keys defined for any of the visible controls.

There are hidden contrl buttons for <Ctlrl-p>, <Ctlrl-e,<Ctlrl-m,<Ctlrl-c>. These buttons are hidden under other panel items so they are not visible. They should only work if the Tx Data control window is active and in focus.

 

The other panels do not have any quit or close controls on them they are displayed and hidden as required.

 

uir1.jpg shows the main panel

quit.jpg shows the settings for the 'Quit' button

QuitExample.jpg shows the app when this happens: Note that all the control buttons are dimmed except for 'Abort' and 'Quit', STATUS which is a display window that is active and just shows info and ...

 

ONLY 'ABORT' and 'QUIT' should be available to the USER! 'Power' should not be available, STATUS should be visible but not tab-able as well as the two unknow ones from the previous post.

 

I will include the code for callbacks.

 

Is there a way to change how the defalt keys are handled? 

Can the 'Enter' and space bar be removed from the default tab list as well as the Power etc.?

 

Thanks for the help.

0 Kudos
Message 8 of 14
(4,583 Views)

I'm not sure of any way to prevent the Enter or Space key from activating either of your Abort or Quit buttons. (From your description I'm guessing that one of these must have the focus at the time this occurs.) Have you considered adding a simple "Are you sure?" pop-up panel, so that the application will not always quit without confirmation from the operator?

 

JR

0 Kudos
Message 9 of 14
(4,580 Views)

I would begin putting breakpoints in all places where the program could quit and see where the quitting event is originated:

 

- QuitCallBack function

- GlobalQuitCallBack function

- The timer callback, inside if (global_quit == TRUE) block

 

Additionally, I surely would try to discover those 2 "phantom controls" you are guessing: take a look at the include file for your UIR and look to all controls. If you are unsure, save the UIR in text format (Options >> Save in text format menu function) and look at it in a text editor trying to discover all active controls (you told there are hidden controls: maybe you are missing one of them).

(Hint: if you place the cursor on a callback name and press Shift + Ctrl + U you will jump to the control that owns the callback; if more than one control own it, you will see a list of all controls / menu items that are linked to the callback)

 

As a last hint, put all controls that are not intended to be operable from the use in indicator mode: this way you will prevent them from being scanned while tabbing on the panel and will ansure no event can be fired by them in any case. If you have controls that need to be operable in some state and not operable in some other, either dim them like you are doing or programmatically change their mode with SetCtrlAttribute(..., ..., ATTR_CTRL_MODE, VAL_INDICATOR) if you don't want to have them dimmed.



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 10 of 14
(4,568 Views)