09-29-2009 06:46 AM
Solved! Go to Solution.
09-29-2009 08:40 AM - edited 09-29-2009 08:41 AM
Joepass:
I see the same behavior in CVI 9.01. Seems strange to allow Ctrl-tab when text editing is disabled.
Why do you need the control to be HOT when you have text editing disabled? Why not just set it to be an indicator?
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_CTRL_MODE, VAL_INDICATOR); // or VAL_HOT to resume editing
If you do want it to be HOT, you can do a workaround by swallowing key press events. Assign a callback function to the textbox control (by editing the control in the UIR editor), check if text editing is disabled, and if it is, swallow any keypress event by returning 1. See the CVI help on Swallowing Events for more info.
int CVICALLBACK textboxCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int no_edit_attr;
switch (event)
{
case EVENT_KEYPRESS:
GetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_NO_EDIT_TEXT, &no_edit_attr);
if (no_edit_attr)
// swallow event if text box is set to no edit
return 1;
break;
}
return 0;
}
09-29-2009 09:37 AM
09-29-2009 11:30 AM - edited 09-29-2009 11:40 AM
Joepass:
I tested the code I posted. Swallowing the key press event does work for Ctrl-Tab (meaning that the control text does not get modified when you press Ctrl-Tab). The callback is made before the control is updated. That's the whole point of callbacks. If you swallow the keypress event (as in the code I posted), Ctrl-Tab will not overwrite the text.
I have attached a sample project that shows how swallow events will help you. Run it and follow the instructions on the screen.
09-29-2009 11:50 AM
Dear Al S,
marvelously, thank you indeed.
Best regards.
JS
10-08-2009 12:13 PM
Hi JS,
Just a quick note to let you know that we agree that this does look like a bug in CVI, and it will be resolved in a future release. The problem report is 190831.
Thanks for reporting this.
Luis