From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Key Focus not working properly

I'm apologizing in advance for this one...

I've been trying to get this to work for about 20 minutes and have decided that's far too long to be trying to do this.

What I want to happen is for the Key Focus to be on one control, when the enter key is struck move to the next control, and when enter is hit again, moves to the button, and if an incorrect value has been entered, the Key Focus is returned to the first control.  This is all well and good the first time through, but for some reason, it won't return the Key Focus to the first control.  If I click on it and then hit enter, it goes through the routine as it should, but again, won't return to the first control.

This is just to eliminate having to use the mouse, and I'm sure it's just something stupid I've missed, but...
0 Kudos
Message 1 of 12
(3,686 Views)
I do not understand how you tell the program that an incorrect value has been entered. If I enter a value into CW and hit Enter, focus moves to CCW. Hitting enter again (with non-zero value) moves focus to Done. Hitting Enter with focus on Done activates teh button and stops the program. Maybe you should use Tab to move from one control to the next and Enter for completion. You can remove a control from the tabbing order, I think.

Lynn
0 Kudos
Message 2 of 12
(3,680 Views)
Well, I'm not monitoring whether an incorrect value has been entered, only one that could possibly exist.  I only want to make sure that they don't enter a value <=0.

The values are output to a higher level vi in order to be included on a report.  The reason for this little vi is that this is not something we are currently capable of automating (as the program I am writing is just an automation of a manual test), so the operator is to perform the Detent Torque test, and then come to the test stand to run the test.  The information is needed to be included on the report that I generate after the test is complete.

I just can't seem to get it to cycle through properly with ALL 0 values...  I should have mentioned that in my first post...sorry 'bout that.

I have since discovered that if I remove the dialog box, and just wire a true constant to the KeyFocus (in the case structure), that it works.  But since the output of the dialog box is wired to the input of the property node, it should set the KeyFocus no matter what...unless it's somehow violating the dataflow...
0 Kudos
Message 3 of 12
(3,668 Views)
I agree this should not be a 20 minute problem.  Your code looks like it should work fine but there must be some subtle property node behavior at play that isn't apparent.  With highlight execution on, it works fine.  Even running real time, the value probed out of the dialog VI is correct.  I was able to get it to work when I added a 1ms delay between the dialog box VI and the CW keyfocus node using a flat sequence structure.  That is just a workaround though.
0 Kudos
Message 4 of 12
(3,666 Views)

Hi guys,

  This may not be the most elegent solution, but could you just change the data range so that it is impossible to set the number at 0 or below.  I'm working in Labview 6.1 and I'm not sure if 7 has the same function, but I don't see why it wouldn't.  Simply right click on the control and select Data Range...  Again, not the most elegent solution, but I don't see why it won't work.  Good luck,

PP

Message 5 of 12
(3,661 Views)
Yeah, I found a few workarounds too (along the lines of yours), but I just don't understand why it would, if only very quickly, violate the dataflow.
0 Kudos
Message 6 of 12
(3,659 Views)
I suspect then the problem is with the dialog box.  Perhaps you are trying to adjust the key focus too soon because the key focus is actually on the dialog box that pops up.  It has yet to fully relinquish its keyfocus 'token' or whatever when the data exits the dialog box VI.
Message 7 of 12
(3,640 Views)
The pop up message interferes with key focusing from labview code (don't know why, but it does).  Add a boolean control, and use value(signaling) to set the key focus.  This works fine, see attached vi:
- tbob

Inventor of the WORM Global
Message 8 of 12
(3,633 Views)

I have cleaned up the code a bit, which made the basic operation more consistent--and easier to understand, I think at least. In terms of your error condition, the problem is the built in dialog box function. It apparently returns execution to LV before it gets it's window shut. Put in a small delay or turn on execution highlighting and everything works fine. However, the solution is don't use the funky popup function. I have a dialog box VI I created a long time ago so my programs would have a consistent interface. I put that in instead of the popup and everthing worked as expected without any delays...

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 9 of 12
(3,623 Views)
Thanks for everyone's help.  I figured it was something to do with the dialog box, but wasn't sure why.

Thanks again
0 Kudos
Message 10 of 12
(3,611 Views)