NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Button clicked flashes but must click again for action

I found this code in tsutil.c which has comments that appear to be addressing the problem area.
For some reason, a programmer wanted to ignore the first click on a tab, and added code to do so.

I tried to comment out the first three lines under case EVENT_TAB_CHANGED:
I created a new obj file and copied it to the various directories. I rebuilt modelsupport2 which includes tsutil.
I don't know what other project modules should be re-built. Thus far, the problem hasn't been solved.

As per the comments below, the user is trying to click on a button on different tab than the last mouse click;
the button control (e.g. Test UUT) flickers, but does nothing.

Am I in the right area? What else uses tsutil and needs to be rebuilt to solve this issue? Is there a
similar workaround somewhere else in the TS code that I must modify?


static int CVICALLBACK TS_ExprCtrl_PanelCallback (int panel, int event, void *callbackData, int eventData1, int eventData2)
{
int error = 0;
int activePanel;
int activeCtrl;
TS_ExprCtrl * exprCtrl;
TS_ExprCtrl_Flags flags = (TS_ExprCtrl_Flags)callbackData;


switch (event)
{
case EVENT_LOST_FOCUS:
case EVENT_GOT_FOCUS:
// controls do not get focus events when their panels gain or lose activation. Thus we need to check explicitly
activePanel = GetActivePanel();
if (activePanel > 0)
activeCtrl = GetActiveCtrl(activePanel);
else
activeCtrl = -1;

// This originally only visited the panel that got the event. However, apparently you can click on a parent and get a focus
// event without any event going to the previously active child?
errChk( TS_ExprCtrl_UpdatePanelFocusStateForGivenActiveCtrl(panel, TRUE, activePanel, activeCtrl));
break;
case EVENT_TAB_CHANGED:
if (!(flags & kTS_ExprCtrl_UseNormalTabCtrlActivation))
DisableFirstCtrlActivationParentTabCtrl(panel); // force any easytab ctrls to never active a control when switching tabs
else
{
// When you click on an inactive tab, EasyTab might make the first control in the tab active or it might make the tab itself active
// depending on whether a control in the previous tab was active. If makes the control active, it also makes the tab panel active.
// This causes the control to draw. Since we haven't gotten a focus event yet, it has the non-focus display value in it.
// We then get a focus event we then draw the focus display value. Thus the control flickers.
// To fix this, when we get the EVENT_TAB_CHANGED event, we pretend like the control has the focus
// so that it is set to its focus display value. We then post a deferred callback to recheck the focus.
// If easytab sets the control to have the focus and activates the panel, the correct value is already displayed
// and our callback will not change it. If easytab does not activate the panel then our callback will
// set the display value back to non-focus value before the screen is redrawn.

if (eventData1 == panel)
{
int activeCtrl;

if (ActivateFirstCtrl(panel))
{
activeCtrl = GetActiveCtrl(panel);

if (activeCtrl > 0)
{
if (GetChainedCallbackData (panel, activeCtrl, kTS_ExprCtrl_Id, (void **)&exprCtrl) >= 0)
errChk( TS_ExprCtrl_UpdateFocusStateForGivenActiveCtrl(exprCtrl, panel, activeCtrl));
}
}

PostDeferredCallToThread(CheckFocusNow, (void *)panel, CurrThreadId ());
}
}
break;
}

Error:
return 0;
}
0 Kudos
Message 11 of 11
(729 Views)