LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

'Enter' quits app.

Solved!
Go to solution

As Menchar and Roberto have pointed out, the most likely scenario is that your Quit button is the active control at the time that the Enter key is pressed. You could confirm this by adding a GetActiveCtrl call to your code as you quit your program (but before you discard the panel).

 

Earlier you mentioned that the Quit button does not have the outline drawn around it to indicate that it's active. But that's a not a foolproof way of indicating whether it's active. If, for example, your UI is not processing events, the control might not have had a chance yet to update its look after changes in your program.

 

You also mentioned that you were activating a different control at the beginning of your control. But if the control that you're activating is dimmed at the time, or is dimmed after you activate it, then the focus will necessarily change to another control, possibly your Quit button. Finally, if the Quit button is the only non-indicator, non-dimmed control in the panel, then it necessarily has to have the focus.

 

Note that even when the Quit button has the focus, if the user presses the Enter key, the button's callback does receive an EVENT_KEYPRESS. You can, if you wish, respond to this event and return 1 from the callback function, which will prevent the control from then receiving the EVENT_COMMIT.

 

Luis

Message 11 of 14
(1,434 Views)

Roberto,

 

Huge tip on the save uir as text!

 

I found the phantom controls and dimmed them (POWER, Ctrl-p, STATUS no longer tab which is correct).

I did find a hidden button 'Global Quit'. I only call the GlobalQuit callback in code so I don't believe I even need that button. I will delete it.

 

Now that leaves the two control buttons 'Abort' and 'Quit'. These are the two choices for the user to select.

 

How do I disable the 'Enter' or space bar from selecting them.

I only want the user to be able to select them with a mouse click only so they have to be non-dimmed.

 

Thanks.

0 Kudos
Message 12 of 14
(1,425 Views)
Solution
Accepted by topic author NI Nubie

Hi LuisG,

 

I put the following code snippet in the 'Quit' and 'Abort' callbacks and that fixed the space bar and 'Enter' issue.

The buttons now only work with a mouse click.

 

case EVENT_KEYPRESS:
   return (1);
   break;

Thanks ALL for your valuable responses!

0 Kudos
Message 13 of 14
(1,403 Views)

Let me correct the code programmatically:

 

.....

case EVENT_KEYPRESS:
   return_val = (1);
   break;

.......

 return (return_val);

}

0 Kudos
Message 14 of 14
(1,392 Views)