Search code examples
visual-c++wxwidgets

wxwidgets wxtreectrl wxTR_HAS_BUTTONS does not enable plus minus buttons next to tree


When I create a treectrl item with wxTR_HAS_BUTTONS enabled, no buttons seem to show. I am compiling using VC++ 2008.

    treectrlModelTree = new wxTreeCtrl( itemPanel3, ID_TREECTRL_MODEL_TREE, wxDefaultPosition, wxDefaultSize, wxTR_EDIT_LABELS|wxTR_HAS_BUTTONS |wxTR_SINGLE|wxSUNKEN_BORDER );

I am adding the root with:

wxTreeItemId rootId = treectrlModelTree->AddRoot("Model Tree", -1, -1,  new MyTreeItemData((void*)group));

and appending data to the tree with the AppendItem() command:

wxTreeItemId tempItem = treectrlModelTree->AppendItem(groupId, tmpstr, -1, -1, new MyTreeItemData(tracker->model));

I tried searching around but it does not seem like there are too many posts online about treectrl problems.


Solution

  • I figured it out,

    It has to do with a bug in wxwidgets 2.8.9 where dragging items within the treectrl will give an error when there is no images assigned to a treectrl (i.e. folder images).

    See: [http://trac.wxwidgets.org/ticket/4390][1]

    I was using a quick fix suggested, to add a dummy image list

    treectrlModelTree->AssignImageList(new wxImageList(1, 1));
    

    which suppressed the plus/minus buttons for the treectrl.