LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CTRL_MODE=VAL_INDICATOR + GetFocus ?

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

0 Kudos
Message 1 of 5
(4,105 Views)

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;
}



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?
Message 2 of 5
(4,101 Views)
Thanks for this, there are times it annoys me too! OTOH, there are times I need to let the users cut and paste from an indicator, but at least now I have the option. --wally.
0 Kudos
Message 3 of 5
(4,091 Views)

simple and good - thanks roberto !

0 Kudos
Message 4 of 5
(4,087 Views)

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,

S. Eren BALCI
IMESTEK
0 Kudos
Message 5 of 5
(4,072 Views)