Showing results for 
Search instead for 
Did you mean: 

ATTR_NO_EDIT_TEXT does not work correctly at CTRL + Tab key combination.

Go to solution
Hello all, 
I set a text box (control mode = hot) to the attribute ATTR_NO_EDIT_TEXT. Thus the text cannot be overwritten over the keyboard. But the key combination CTRL + Tab inserts Tabs and overwrites marked texts with a Tab (4 blanks).
Can this be prevented somehow, but so, that the control mode of the text box remains on "hot"?
Thanks in advance.
LabWindowsCVI 9.0
0 Kudos
Message 1 of 6



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)
   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;
 return 0;

Message Edited by Al S on 09-29-2009 08:41 AM
0 Kudos
Message 2 of 6
Hi dear Veteran,
Thanks, but independently how callbacks are treated over EVANT_KEYPRESS, CTRL + TAB overwrites the text before the callback is call.
I need the HOT mode, because I must mark (just in HOT-Mode) automatically text in the opend window before change to edit mode.
How I can solve my problem with swallow events, I must still consider myself. Thanks already for the hint.
Thanks again. 
0 Kudos
Message 3 of 6
Accepted by topic author 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.

P.S.  I still don't understand why you need the control to be HOT when you don't want text entered.  You can programmatically go back and forth between VAL_INDICATOR and VAL_HOT as I described in my first reply.
Message Edited by Al S on 09-29-2009 11:40 AM
Message 4 of 6

Dear Al S,


marvelously, thank you indeed.


Best regards.


0 Kudos
Message 5 of 6

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.



0 Kudos
Message 6 of 6