LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Misbehaviour of listbox in check mode operated by keyboard

Hello,
i want to use the listbox under LabWindows to select some channels. The listbox is in check mode and if the control sends a EVENT_MARK_STATE_CHANGE, i read out the checkmark by the "IsListItemChecked" function. This works fine in case the control is operated by mouse. If the user checks an entry by keyboard space bar, the read out data is inverse. With activated "draggable marks" property of the listbox control, the information of the checkmarks are inverse in any case.
I tried a bit around with the EVENT_COMMIT and EVENT_VAL_CHANGED, but they don't deliver the item index in mouse and keyboard operation.
0 Kudos
Message 1 of 2
(2,616 Views)
The problem related to your program is that when you use the spacebar for checkmarking an item and the EVENT_MARK_STATE_CHANGE event is processed the listbox isn't updated. The update is done when the EVENT_COMMIT event is passed into your callback. The following change in your program will help:

int CVICALLBACK cb_Listbox (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int checked;
int len;
char *sEntry;
int idx;

switch (event)
{
case EVENT_COMMIT:
GetCtrlIndex (panel, control, &idx);
GetLabelLengthFromIndex (panel, PANEL_LISTBOX, idx, &len);
sEntry = malloc(len+32); // Alloc a little bit more data
GetLabelFromIndex (panel, PANEL_LISTBOX, idx, sEntry); // get label
IsListItemC
hecked (panel, PANEL_LISTBOX, idx, &checked);
if (checked == 1)
sprintf(sEntry, "Entry %i is checked", idx);
else
sprintf(sEntry, "Entry %i is not checked", idx);
ReplaceListItem (panel, PANEL_LISTBOX, idx, sEntry, idx);
free(sEntry);

break;
}
return 0;
}

Regards,
Heinrich Illig
National Instruments
Message 2 of 2
(2,616 Views)