objective c - NSTableView with Dropdown Menu and having Image inside Menu -
yes, possible have:
- a table having 2 column ( should easy)
- one of cell should have image , should selectable drop - down menu
googling came know has of type nspopupbuttoncell type, want image inside it, no text,
how can ? - the column editable, user should able type in that.
it great if can reference code implement same.
i did following way,
in coloumn 1 select datacell , assign of type nspopupbuttoncell, default wouldn't come, need select explicitly.
in code add following lines of code...
nstablecolumn *option = [ptablecolumns objectatindex:[ptableview columnwithidentifier:option_column_name]]; nstablecolumn *shortcutitem = [ptablecolumns objectatindex:[ptableview columnwithidentifier:shortcut_column_name]]; // want first cell have image & menu //data type column drop down nspopupbuttoncell *datatypedropdowncell = [option datacell];//[[nspopupbuttoncell alloc] inittextcell:@"" pullsdown:yes]; [datatypedropdowncell setbordered:no]; [datatypedropdowncell seteditable:yes]; nsarray *datatypenames = [nsarray arraywithobjects:@"nullorignal", @"string", @"money", @"date", @"int", nil]; [datatypedropdowncell additemswithtitles:datatypenames];
add following code set correct menuitem
- (void)tableview:(nstableview *)atableview willdisplaycell:(id)acell fortablecolumn:(nstablecolumn *)atablecolumn row:(nsinteger)rowindex{ if([[atablecolumn identifier] isequaltostring:option_column_name]){ nspopupbuttoncell *datatypedropdowncell = [atablecolumn datacell]; [datatypedropdowncell selectitem:[ datatypedropdowncell itematindex:3]]; } }
now pending append image inside menuitem not big deal @ all,
again looking @ this, let me know if other approach there so....
Comments
Post a Comment