Opened 9 years ago

Closed 6 years ago

#11179 closed defect (fixed)

TreeCtrl AppendItem/EditItem display bug under OS X

Reported by: fengb Owned by:
Priority: normal Milestone:
Component: wxOSX Version: 2.8.10
Keywords: Cc:
Blocked By: Blocking:
Patch: no


When appending a new child to an expanded parent and editing it immediately, the edit box appears in an unexpected location. As far as I can tell, the edit can be used blindly, but it does not properly display the result until the editing is finished.

Appending and editing the child to a collapsed parent will work normally.

I only managed to reproduce this behavior on OS X; my Windows version works fine.

I have attached a wxPython script that replicates this buggy behavior.

Attachments (1) download (1.2 KB) - added by fengb 9 years ago.

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by fengb

comment:1 Changed 8 years ago by vadz

Would be nice to have a C++ example reproducing this to test if it's still broken.

comment:2 Changed 6 years ago by vadz

I can reproduce the problem with pre-2.9.5 using this patch

  • samples/treectrl/treetest.cpp

    diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp
    index 8e0064d..934450b 100644
    a b void MyFrame::OnAddItem(wxCommandEvent& WXUNUSED(event)) 
    777777    wxString text;
    778778    text.Printf(wxT("Item #%d"), ++s_num);
    780     m_treeCtrl->AppendItem(m_treeCtrl->GetRootItem(),
     780    m_treeCtrl->EditLabel(m_treeCtrl->AppendItem(m_treeCtrl->GetRootItem(),
    781781                           text /*,
    782                            MyTreeCtrl::TreeCtrlIcon_File */ );
     782                           MyTreeCtrl::TreeCtrlIcon_File */ ));

The behaviour is strange, the text control doesn't appear at all actually and editing it blindly doesn't really work neither.

However just removing the special case for wxMac in wxTreeCtrl code seems to fix it so I'll go ahead and just do this -- and wait if any new problems are uncovered by this.

comment:3 Changed 6 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [72882]) Update tree control layout in EditLabel() for wxOSX too.

A special preprocessor check for OS X prevented the control from being relaid
out correctly in EditLabel() there, which resulted in problems when trying to
edit a just added item.

Simply remove this check for OS X (and also MSW but this is less important as
this version of the control is almost never used there anyhow) to fix it.

Closes #11179.

Note: See TracTickets for help on using tickets.