editable listboxes

I am trying to get a listbox cell to be editable, but cannot get it to work.  What am I missing?  Below is the create from the listbox create hook and the Ditem_listboxrsc definition:

case DITEM_MESSAGE_CREATE:
{

int i,numCols=2;

ListModel *pListModel,*usedPListModel;

ListCell *pCell = NULL;

ListRow *pRow = NULL,*newPRow=NULL;

if (NULL == (pListModel = mdlListModel_create (numCols)))

{

dimP->u.create.createFailed = TRUE;

break;

}

usedPListModel = mdlListModel_create (numCols);

if (SUCCESS != mdlLevelList_getLevelNamesListModelEx (pListModel, MASTERFILE, LEVEL_DEFAULT_LEVEL_ID, LEVELLIST_BOLD_USED))

{
mdlListModel_destroy (pListModel, TRUE);

dimP->u.create.createFailed = TRUE;

break;
}

// show only used levels

for(i=0; i<mdlListModel_getRowCount(pListModel); i++) {

pRow = mdlListModel_getRowAtIndex (pListModel, i);

pCell = mdlListRow_getCellAtIndex (pRow, 0);

if(FONT_INDEX_BOLD==mdlListCell_getFontIndex (pCell)) {

mdlListRow_create (usedPListModel);

newPRow=mdlListRow_copy (pRow);

mdlListModel_addRow(usedPListModel,newPRow);
}
}
mdlDialog_listBoxSetListModelP(dimP->dialogItemP->rawItemP,usedPListModel,1);
break;
}

 

DItem_ListBoxRsc LISTBOXID_ExportDTMLevels =
{
NOHELP,
LHELPCMD,
HOOKITEMID_ExportDTMLevelSelection,
NOARG,
LISTATTR_DYNAMICSCROLL |
LISTATTR_RANGESELECTION |
LISTATTR_DISJOINTSELECTION |
LISTATTR_NOSELECTION |
LISTATTR_EDITABLE |
LISTATTR_FONTBYCOLUMN,

8,
0,
"Select Levels",
{
{18*XC,50, ALIGN_LEFT, ""},
{5*XC,3, LISTCOLATTR_EDITABLE | ALIGN_RIGHT, "FC"},
}
};

  • Ray:
    I am trying to get a listbox cell to be editable, but cannot get it to work.

    You are right to use a ListModel, but incorrect in assuming that a ListBox can be edited. The ListBox is merely the presentation device for a ListModel, and presentation devices can't edit.

    Cells in a ListModel can be edited, and the mechanism to achieve that is to assign a cell editor to an individual cell, or more usually to an entire column or row. Take a look at our page that describes MDL ListModels, ListCells, and Cell Editors.

    If you scroll to the end of that page you'll find the Datasheet example, which is a modified version of one that Mark Anderson gave out several years ago.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions