LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling (almost) any front panel changes with an event structure. What is best practice?

I was doing a UI just this week that will scale up at least a hundred controls across multiple front panels (in sub-panels).   Each control has custom menus and hover effects, meaning I capture Shortcut Menu Activation and Selection events, plus three Mouse events (Enter, Down? and Leave), in addition to Value Change.   That would be 600+ cases if I treated every control; with generic techniques I instead have only six.  I don't even use individual control references; I get the array of controls from from a property of the various front-panel panes.  To add new controls I just drop them on the front panel and name them to match the identifier in the configuration information.

0 Kudos
Message 11 of 16
(1,298 Views)

There is a method which makes life a lot easier and that is creating a VI Server reference (for the VI with the menu) and then creating a property node under front panel>Controls[] and registering the array of controls as a dynamic event.  Inside the event structure you decipher which control was actuated by comparing the new value against the old value and then handling each case.  Hope this helps.

0 Kudos
Message 12 of 16
(1,233 Views)

@id wrote:

There is a method which makes life a lot easier and that is creating a VI Server reference (for the VI with the menu) and then creating a property node under front panel>Controls[] and registering the array of controls as a dynamic event.  Inside the event structure you decipher which control was actuated by comparing the new value against the old value and then handling each case.  Hope this helps.


 

This will not affect controls inside containers such as clusters and tab panels.

Also, I would not recommend this if you actually need to know which control was accessed. Use the standard error handling by control for that.

 

I am looking at this because my users do not want the up/down arrow keys on our numeric fields. This is a case where I don't need to know what control was pressed, but I need to do the same for all of them.  Our controls are in a tab and many are in clusters. Unfortunately I am looking at adding a reference to each individually, even though I already store all references to the clusters.

0 Kudos
Message 13 of 16
(997 Views)

Is there any reason you can't put those booleans in a cluster, then catch a Value Change on the cluster?

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 14 of 16
(977 Views)

Threads like this one are helpful because several options are given for readers to consider.

 

One thing not specifically addressed so far is that the OP (not seen for 4 years) mentioned that some

changes will not be allowed based on the state of the system. Using a Value Change event will always

result in a visual indication of the Boolean changing (at least temporarily). In these cases I use a Mouse Up

event and provide a user message if the change is not allowed. 

 

For example: "You can't close this valve because the flow rate is above 300 gpm".

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 15 of 16
(962 Views)

@gabnaim wrote:

 Our controls are in a tab and many are in clusters. Unfortunately I am looking at adding a reference to each individually, even though I already store all references to the clusters.

I haven't looked at the rest of the thread, but this isn't actually an issue. It is possible to recursively iterate through all the containers (like tab controls and clusters) to get the references of the owned controls and add them to your array. It does require casting the references to the specific class to get the properties you need (Pages, Controls[], etc.) and should be findable online, although I can't think of an example offhand.

 

Another option is to enable VI scripting and then use the Traverse for GObjects VI and ask it for all the "Control"s. I think this works in executables as well, but I'm not sure, so I would suggest checking.

 

A different option might be to get the Key Down? event for the VI itself and then check the FocusObj terminal to see if it's a numeric and if it is, discard the event.


___________________
Try to take over the world!
0 Kudos
Message 16 of 16
(950 Views)