LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dr. Damien's Development - Programmatic Tab Order

Have you ever wanted to have (almost) complete dynamic control over what controls you include in your tab order?  How about automatically tabbing into clusters and across tab page boundaries.  Would you like to tab into and out of subpanels seamlessly?  You can do all of this with some fairly simple code.  See the attached example.

 

 Programmatic Tabbing Code

 

The basic idea is as follows.

  1. Create an array of all the control references you would like to tab between.  This array can be dynamically generated.  For example, when you load a subpanel, it can return an array of control references which are inserted at a predetermined point into a static set of references of your main panel.
  2. Using the <This VI> Key Down? event, look for Tab (ASCII 9) and Shift Tab keys.
  3. If you find a Tab or Shift Tab, compare the current focus object with your array of possible tab targets.  If it is in the target set, increment to the next possible target and set focus.  If not pick the beginning or end of the list depending on whether or not a Shift is present.
  4. If the target cannot accept focus (e.g. it is currently not visible), loop until a good target can be found.  This code does not explicitly implement it, but you should make sure you can not get into an infinite loop here.
Have fun!  Note that this code does not work in LabVIEW 7.1 and earlier due to a difference in the way control references were handled internally.  If you need a 7.1 implementation, let me know.  It is a bit more obtuse and will include some locked VIs due to proprietary code.
Message Edited by DFGray on 12-05-2008 09:25 AM
Download All
Message 1 of 10
(8,963 Views)

This is why I love the filter events. I remember doing something similar when the user wanted to move between fields using the return key - simply use the Key Down? event and replace the key with ASCII 9. I also did the exact same trick (using the FocusObj terminal) to move between tab pages automatically.

 

P.S. For what it's worth, a VI wrapping the private functionality in 7.x was already posted in the past here, so there's no need to post it again.


___________________
Try to take over the world!
Message 2 of 10
(8,893 Views)
Damien, you might also wish to do what we did with the nuggets (link to your article in the nugget thread and link to the nugget thread in your article). This allows people to actually find these.

___________________
Try to take over the world!
Message 3 of 10
(8,891 Views)
About half a year ago a colleague of me was working on a similar solution in LV 7.1. The solution was not a general one but have to take another thing into account. The programm is running on a tester with only a touch screen. Additional the tester has a wheel simulation the Tab, Shift+Tab and Return key. We are getting these actions on the wheel over serial communication into the program. In this case we not only need to react on Key Down filter events but also on user defined events. The code shown in your screen shot was moved to a SubVI as a general handler for the control taken into consideration.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 10
(8,816 Views)
I will do that in the future.  Thanks for the suggestion!
0 Kudos
Message 5 of 10
(8,771 Views)

See attached for Damien's example calling subVI with error clusters and conditional for loop (to resolve aforementioned infinite loop issue).  It is now safe to enable automatic error handling:  To More Specific Class throws an error with the first tab key down due to an initial null FocusObj ref.

 

SubVI can be dropped into any Key Down? event.

 

Nice work Damien,

Jason


Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
0 Kudos
Message 6 of 10
(8,648 Views)

Bug fix:  Using this method, dynamic tabbing does not work on controls when the containing VI is inside a Subpanel because the event structure returns the Subpanel control as the FocusObj instead of the control with actual focus.

 

Note:  the Subpanel VI must be running for one of its controls to receive key focus.

 

See attached for an updated VI or below for a screenshot of the fix:

 

Dynamic Tabbing into Subpanel Fix.png


Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
Download All
Message 7 of 10
(5,837 Views)

Actually, the original code worked very well with subpanels.  That is why I created it.  Thanks for the heads up that something has changed.  I will see if I can track down what and when.

0 Kudos
Message 8 of 10
(5,799 Views)

Thanks Damien.  While you're looking into subpanels under-the-hood, there are 2 other bugs that would be great to fix:

 

1:  IDE allows loading CTL files into a subpanel, but crashes intermittently (CAR 380143).  CTLs load fine once EXE is compiled.

2:  VI must be running for its controls to receive key focus once loaded into subpanel (i.e. to allow dynamic tabbing).

 

I wrote a tool that allows developers to load any CTL file into a universal configuration dialog via subpanel, which retrieves/stores info using GXML calls.  #1 above prohibits this directly, so I placed the CTL on a VI panel with no diagram code as a work around only to discover #2.  In the end it's working, but developers have to maintain a runable VI for each respective CTL.


Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
0 Kudos
Message 9 of 10
(5,779 Views)

Re-edited Damien's VIs with the modifications mentioned above and attaching here.  The previously edited VIs attached above had gone through a corporate routine that automatically added a copyright notice on repository check-in that I didn't catch before posting.


Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
Download All
Message 10 of 10
(3,843 Views)