问题
Hi I have a simple VI to press a button to turn on the led. My code works just fine except I would like to have the button to be back to normal color after pressing. I tried all the mechanical actions, but none of them does what I want it to do.
The procedure is as follows:
- Say before user presses the button it appears like this
- After user presses the button it becomes
- Then the led turns on
- Once it executes the event the button goes back to
The block diagram is shown below:
I am puzzled and could someone please help me ?
回答1:
The reason the Latch mechanical action isn't working for you is that a Value Change Event on a Latched Boolean will not trigger its mechanical action. In order to trigger the mechanical action, you have to read directly off the Boolean terminal on the block diagram. This is explained in the LabVIEW Help under "Using Events with Latched Boolean Controls".
If you want the boolean to latch, make sure its set to the Latching mechanical action, and then use the actual terminals value to turn the boolean indicator on/off rather than a constant. I've also added a Case Structure to the OK Button to ensure the boolean indicator is only updated when the "OK Button" is enabled.
Here's a VI Snippet showing the latch in action.
来源:https://stackoverflow.com/questions/48514797/labview-ok-button-doesnt-update-its-color-after-pressed