LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Table action on enter key

Hi,

When editing a string cell in a table, is it possible to make the enter
key move to the next column rather than the nest row and remain in edit
mode?
--
Regards,

John Cameron.
0 Kudos
Message 1 of 4
(3,327 Views)
In message <36lvQlDH0s$$EAIQ@ob5.co.uk>, John Cameron
writes
>Hi,
>
>When editing a string cell in a table, is it possible to make the enter
>key move to the next column rather than the nest row and remain in edit
>mode?
Sorry, I should have said version 6.
--
Regards,

John Cameron.
0 Kudos
Message 2 of 4
(3,327 Views)
Yes, you can do this fairly easily. All you have to do is catch the KEYPRESS event in the table's callback, and then change the active cell yourself, taking care to "swallow" the original event. The following code should do the trick:

case EVENT_KEYPRESS:
GetCtrlAttribute (panel, control, ATTR_TABLE_RUN_STATE, &state);
if (state == VAL_EDIT_STATE)
{
keyCode = GetKeyPressEventVirtualKey (eventData2);
if (keyCode == VAL_ENTER_VKEY)
{
GetActiveTableCell (panel, control, &cell);
GetNumTableColumns (panel, control, &numColumns);
if (cell.x < numColumns)
{
cell.x++;
SetActiveTableCell (panel, control, cell);
S
etCtrlAttribute (panel, control, ATTR_TABLE_RUN_STATE, VAL_EDIT_STATE);
}
return 1;
}
}
break;

Luis
NI
0 Kudos
Message 3 of 4
(3,324 Views)
In message <506500000005000000D64B0100-1073519706000@exchange.ni.com>,
LuisG writes
>Yes, you can do this fairly easily. All you have to do is catch the
>KEYPRESS event in the table's callback, and then change the active
>cell yourself, taking care to "swallow" the original event. The
>following code should do the trick:
>
>case EVENT_KEYPRESS:
> GetCtrlAttribute (panel, control, ATTR_TABLE_RUN_STATE, &state);
> if (state == VAL_EDIT_STATE)
> {
> keyCode = GetKeyPressEventVirtualKey (eventData2);
> if (keyCode == VAL_ENTER_VKEY)
> {
> GetActiveTableCell (panel, control, &cell);
> GetNumTableColumns (panel, control, &numColumns);
> if (cell.x < numColumns)
>
{
> cell.x++;
> SetActiveTableCell (panel, control, cell);
> SetCtrlAttribute (panel, control,
> ATTR_TABLE_RUN_STATE, VAL_EDIT_STATE);
> }
> return 1;
> }
> }
> break;
>
>Luis
>NI

That worked. Thanks Luis.
--
Regards,

John Cameron.
0 Kudos
Message 4 of 4
(3,324 Views)