07-10-2013 02:57 PM
I have a table with many rows and columns. I want to "disable" some cells such that users can see them but when they click/double click on that cell nothing happens.
In my code I have callback function for the table and based on user's table cell selection (Doubleclick) I perform some action.
I tried cell attributes Dimmed and changed mode to indicator but when I doubleclick on cell It still generates double click events.
SetTableCellAttribute (panelMain, MAIN_TABLE_COMMAND,MakePoint (1, i), ATTR_CELL_DIMMED, 1);
SetTableCellAttribute (panelMain, MAIN_TABLE_COMMAND, MakePoint (1, i), ATTR_CELL_MODE, VAL_INDICATOR);
07-11-2013 07:55 PM
Hey test_man,
It looks like there is an attribute you can set called ATTR_NO_EDIT_TEXT in SetTableCellAtrribute
http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/uiref/cviattrnoedittext_cell/
Let me know if this accomplishes the functionality you desire.
Best Regards,
-KP
07-12-2013 08:29 AM
I tried this. It doesn't solve my problem.
My table callback function still receives double click event even after I enable no edit for that cell. I couldn't edit that cell after double clicking on it so this attribute works as expected for that purpose but it doesn't work for me.
Any other ideas?
07-15-2013 06:04 PM
Have you tried swallowing the double click event in the callback? A double click event will still be generated, but if you swallow the event, it will not be passed on to further callbacks and does not appear editable. Refer to swallowing events.
To do this, you will need to implement the logic yourself for checking if the cell is to be ignored or not. Here is a snippet of code that does this for a couple cells that I setup in earlier code. I used a List to hold the Points that I would like to ignore, but there are other data structures that may make more sense for you application.
//setup ignored cells list in earlier code
ignoredCells = ListCreate (sizeof(Point));
cell = MakePoint(1, 2);
ListInsertItem (ignoredCells, &cell, END_OF_LIST);
cell = MakePoint(1, 3);
ListInsertItem (ignoredCells, &cell, END_OF_LIST);
int CVICALLBACK tableCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_LEFT_DOUBLE_CLICK:
Point cell;
int current = 0;
//get the currently selected cell
GetActiveTableCell(panelHandle, PANEL_TABLE, &cell);
//check if the cell is in my ignored cell list
if(isIgnored(cell))
{
return 1; //returning 1 swallows the event
}
//Actions taken if the cell is not an ignored cell
GetCtrlVal(panelHandle, PANEL_LED, ¤t);
SetCtrlVal(panelHandle, PANEL_LED, ++current % 2);
break;
}
//return 0 does not swallow the event and allows it to be sent to other callbacks
return 0;
}
int isIgnored(Point selectedCell)
{
int c;
//check if the selected cell is in my ignored cell list
for(c = 1; c <= ListNumItems(ignoredCells); c++)
{
Point cmpCell;
ListGetItem(ignoredCells, &cmpCell, c);
if(PointEqual(selectedCell, cmpCell))
{
return 1;
}
}
return 0;
}
07-15-2013 06:16 PM
Hey test_man,
What are you trying to accomplish? There is not really a way to disable events but you can call ProcessSystemEvents to process all pending events. There is a forum post discussing a very similar situation that you can find here.
Best,
-KP