LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

double precision lost in table control?

Hi to all,
please find attached a CVI 6 example that shows the following unexpected
behaviour:

1. Type in a value in the table control with higher precision than displayed
(e.g. 1.23456768)
2. Finish typing by clicking on another table cell. The table cell displays
the typed in value in the predefined precision of the table (e.g. 1.23)
3. Press the "Read" button. The program reads the content of the table cells
and displays them in separate numeric controls. The typed in higher
precision part of the value is lost!

4. Repeat step 1.
5. Finish typing by pressing Return key
6. Repeat step 3, this time the higher precision part of the value isn't
lost!

It seems, it is important to finish an input to a table cell with the retur
n
key and not by clicking to another cell. I can't imagine that this is the
expected behaviour. Any suggestions to that?

Thanks in advance!
Torsten
0 Kudos
Message 1 of 2
(2,897 Views)
You're right, this is a bug. We've fixed it and it will be included in the next release of CVI. Thanks for reporting it!

In the meanwhile, I came up with a workaround that you can use until the fix is available. It's a bit clunky, but it should work. It's based on the idea of catching the mouse click yourself, before the table control does, and perform the cell switch yourself, without allowing the table to do it. As an example, you can use the following function as the table's callback:

int CVICALLBACK CB_Table (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
Point coord, activeCell, clickedOnCell;
int state;

switch (event)
{
case EVENT_LEFT_CLICK:
GetCtrlAttribute (panel, control
, ATTR_TABLE_RUN_STATE, &state);

// the table has to be in edit mode
if (state == VAL_EDIT_STATE)
{
GetActiveTableCell (panel, control, &activeCell);
PointSet (&coord, eventData2, eventData1);
GetTableCellFromPoint (panel, control, coord, &clickedOnCell);

// the click has to take place in the grid area
if (clickedOnCell.x > 0 && clickedOnCell.y > 0)
{

// the user has to click on a cell other than the one being edited
if (activeCell.x != clickedOnCell.x || activeCell.y != clickedOnCell.y)
{
// change the active cell "manually"
SetActiveTableCell (panel, control, clickedOnCell);
return 1; // swallow the click event
}
}
}
break;
}
return 0;
}


Luis
NI
Message 2 of 2
(2,897 Views)