LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you debounce panel buttons?

One additional possibility could be to react to EVENT_GOT_FOCUS event in the panel callback: raise a global flag when receiving the event and start a simple timer that simply clears the flag and disables itself after some tenth of second. In the quit button callback simply test flag value and return immediately if set.

If you don't like to use global variables, you can place a hidden check box on the panel: set it to 1 in EVENT_GOT_FOCUS panel event and clear it in the timer callback; check its value in quit button callback.



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 11 of 12
(1,056 Views)

Wow, lots of hits on this subject. Thought you might be interested in the final solution (my thanks to Nicolas)

Before:

int CVICALLBACK BITTopExit (int panel, int control, int event,
                            void *callbackData, int eventData1, int eventData2)
{
    if (event == EVENT_COMMIT)
        {
        DiscardPanel (b2handle);
        UndimAllMainPanelButtons ();
        FocusPanel = GetActivePanel();   
        }
    return 0;
}

After

int CVICALLBACK BITTopExit (int panel, int control, int event,
                            void *callbackData, int eventData1, int eventData2)
{
    if (event == EVENT_COMMIT)
        {
        int tmpPanel, tmeCtrl;
        // avoid inadvertent double click
        Delay (0.200);
        while (GetUserEvent (0, &tmpPanel, &tmeCtrl));
       
        DiscardPanel (b2handle);
        UndimAllMainPanelButtons ();
        FocusPanel = GetActivePanel();   
        }
    return 0;
}

It's still in test, but preliminary results look good.

DJW

0 Kudos
Message 12 of 12
(1,008 Views)