07-06-2011 01:29 AM
Hello and sorry for this question, it sounds such basic... But after reading the help, the forum, and the examples I still did not find the answer... so your help is welcome...
In the UI editor, I have set up a table in indicator mode. Now, during run time, I'd like to change a given column to hot allowing the user to change the numeric values.
I have tried SetTableCellRangeAttribute ( ,, VAL_TABLE_COLUMN_RANGE ( 3 ), ATTR_CELL_MODE, VAL_HOT ) but it did not seem to have an effect (return value is 0).
I also added SetCtrlAttribute ( ,, ATTR_TABLE_RUN_STATE, VAL_EDIT_STATE ) but it did not help either.
What's the attribute I am missing here?
Thanks!
07-06-2011 06:03 AM
I may be wrong, but it seems to me that you should set the whole control as HOT and set to indicator mode the columns you do not want the operator to modify.
07-06-2011 06:59 AM
Hi Roberto,
Actually I can't imagine you being wrong
Still for some reason your suggestion does not yet yield the desired result: you are correct that setting the table control to hot using SetCtrlAttribute ( , ,ATTR_CTRL_MODE, VAL_HOT) permits to click on the table and edit the selected column, but as an undesired side effect it allows clicking on all other columns, too...
Is it not possible to separate allow clicking from allow editing?
Thanks,
Wolfgang
07-06-2011 07:57 AM
It's not easy to forbid clicking on a table cell. The easiest way to disable user interaction with some cells is to dim them using SetTableCellRangeAttribute (..., ..., ..., ATTR_CELL_DIMMED, 1); table aspect will bi dimmed, though, which can be undesirable.
Alternatively, I'm afraid your only option is to install a callback on the table and intercept mouse coordinated on click and double click events, this way:
int CVICALLBACK TableCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { Point cell; switch (event) { case EVENT_LEFT_CLICK: case EVENT_LEFT_DOUBLE_CLICK: GetTableCellFromPoint (panel, control, MakePoint (eventData2, eventData1), &cell); if (cell.x != 3) return 1; break; } return 0; }
This won't avoid that the user moves active cell with keyboard, so you will need to trap EVENT_KEYPRESS too and discriminate whether to allow moving or not based on direction of movement and active cell.
07-06-2011 08:08 AM
Geez!
Indeed I don't want to dim columns because users should be able to easily read the contents. And you might have guessed it, your callback approach seems quite expensive to me. I guess it will be easier writing a product suggestion for NI
Thanks anyway, may be I'l change my mind...