LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change Command Button Press color

Solved!
Go to solution

How can I change a command button color when it is pressed and held?

i.e. I want it to turn green momentarily while being pressed.

 

Thanks.

 

0 Kudos
Message 1 of 6
(4,310 Views)

In my opinion the best option you have is to use a toggle button, painted in the desired colours in the two available states. In the callback of the button set its value to 0 immediately before exiting:

 

SetCtrlVal (panel, control, 0);



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(4,306 Views)
I tried that but the on color does not show up because it is too fast.
0 Kudos
Message 3 of 6
(4,293 Views)
>I tried that but the on color does not show up because it is too fast.

Respond to EVENT_LEFT_CLICK_UP
--
Guillaume Dargaud
http://www.gdargaud.net/


Message 4 of 6
(4,271 Views)

The visual state of the controls is not updated while inside the callback: that is why you don't see the control in ON state. Insert a ProcessDrawEvent ( ) as the very first instruction in your EVENT_COMMIT callback, next proceed with the rest of the code. You will see at lease a flash of the ON color.

Tell us if the ON state time is too short so that we can suggest some additional hint.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 6
(4,249 Views)
Solution
Accepted by topic author NI Nubie

The EVENT_LEFT_CLICK_UP achieved the desired effect. The toggle button now displays the 'On' colour until the button is released.

 

Thanks all.

0 Kudos
Message 6 of 6
(4,246 Views)