LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Table Cell Attribute Dimmed-Still sends events. I need to disable some table cells to restrict callback event.

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

 

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 1 of 5
(3,907 Views)

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

Kurt P
Automated Test Software R&D
0 Kudos
Message 2 of 5
(3,881 Views)

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? 

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 3 of 5
(3,868 Views)

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, &current);
            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;
}

 

National Instruments
0 Kudos
Message 4 of 5
(3,841 Views)

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

Kurt P
Automated Test Software R&D
0 Kudos
Message 5 of 5
(3,839 Views)