09-17-2010 08:53 AM
hi all,
i gave a slider the CTRL_MODE=VAL INDICATOR. but after that I can click into the DIGITAL_DISPLAY and give the focus to this. is there a possibiliy to avoid this ?
best regards and thanks
Simon
09-17-2010 09:34 AM
The reason why NI let an indicator to gain the focus is to permit the operator to copy and paset its content in case he wants to save some data.
In any case, this annoys me too so I developed this little callback to be installed on all indicators which prevents them from having focus:
int CVICALLBACK rejectFocus (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event) {
        case EVENT_COMMIT:
        case EVENT_RIGHT_CLICK:
        case EVENT_LEFT_CLICK:
            return 1;
        default:
            break;
    }
    return 1;
}
09-17-2010 10:25 AM
09-17-2010 10:52 AM
simple and good - thanks roberto !
09-17-2010 08:46 PM
Just for information:
This is made possible by the return 1 statement.
It is called "event swallowing" and it can be applied to other cases as well.
After CVI callback is done with the event, it prevents other Windows related defualt callbacks from running.
You may run into other situations where you might need this behaviour.
So keep it in mind 😉
Hope this helps,