Click breaks editable agw.CustromTreeCtrl

Platform: Win7x64, wxPython 3.0.2.0

I have a agw.CustomTreeCtrl instantiated with wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_EDIT_LABELS (both flags are important for this issue). When I edit a tree item and then click somewhere outside the edit box, the edit-mode doesn’t end and the editbox stays there forever. The problem is best exhibited by clicking somewhere at the end of the edited item row.

Example code:

import wx
import wx.lib.agw.customtreectrl as ctc

class MyFrame(wx.Frame):
def init(self, parent):
wx.Frame.init(self, parent)

    sizer = wx.BoxSizer( wx.VERTICAL )
    self.SetSizer( sizer )
   
    custom_tree = ctc.CustomTreeCtrl(self, agwStyle=wx.TR_DEFAULT_STYLE|wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_NO_LINES|wx.TR_EDIT_LABELS)

custom_tree = wx.TreeCtrl(self, style=wx.TR_DEFAULT_STYLE|wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_NO_LINES|wx.TR_EDIT_LABELS)

    sizer.Add( custom_tree, 1, wx.ALL|wx.EXPAND, 5 )

    root = custom_tree.AddRoot("Root Item")
    last = custom_tree.AppendItem(root, "item 1")

if name == “main”:
app = wx.App(False)
frame = MyFrame(None)
frame.Show()
app.MainLoop()

``

When the CustomTreeCtrl is replaced with the standard TreeCtrl, the same code works fine.

Do I miss anything, or is this a bug in the CustomTreeCtrl?

Reported as bug #17488, patch provided.