diff --git a/CHANGES.rst b/CHANGES.rst index fff62f65..8691a26a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -70,6 +70,9 @@ Changes in this release include the following: * Fix OGL's ShapeCanvas to draw properly when the window is scrolled, and to also adjust the mouse coordinates, etc. (#635) +* Fixed HtmlWindow's OnFoo virtual methods so calls to them are propagated to + the Python class. (#642) + diff --git a/demo/HtmlWindow.py b/demo/HtmlWindow.py index 7b2eaffd..fa61be83 100644 --- a/demo/HtmlWindow.py +++ b/demo/HtmlWindow.py @@ -37,7 +37,7 @@ class MyHtmlWindow(html.HtmlWindow): if isinstance(cell, html.HtmlWordCell): sel = html.HtmlSelection() self.log.WriteText(' %s\n' % cell.ConvertToText(sel)) - super(MyHtmlWindow, self).OnCellClicked(cell, x, y, evt) + return super(MyHtmlWindow, self).OnCellClicked(cell, x, y, evt) diff --git a/etg/htmlwin.py b/etg/htmlwin.py index d77c1557..e05e78bc 100644 --- a/etg/htmlwin.py +++ b/etg/htmlwin.py @@ -37,15 +37,22 @@ def run(): c = module.find('wxHtmlWindow') assert isinstance(c, etgtools.ClassDef) tools.fixWindowClass(c) - c.bases = ['wxScrolledWindow'] - - c.find('OnCellClicked').ignore(False) - c.find('OnCellMouseHover').ignore(False) - c.find('AddFilter.filter').transfer = True - + c.bases = ['wxScrolledWindow', 'wxHtmlWindowInterface'] tools.fixHtmlSetFonts(c) - # Pure virtuals inherited from wxHtmlWindowInterface + c.find('AddFilter.filter').transfer = True + + # Turn the virtual flag back on for some methods + for name in [ 'OnLinkClicked', + 'OnOpeningURL', + 'OnSetTitle', + 'OnCellMouseHover', + 'OnCellClicked']: + c.find(name).isVirtual = True + c.find(name).ignore(False) + + # Declare that the pure virtuals inherited from wxHtmlWindowInterface have + # implementations here c.addItem(etgtools.WigCode("""\ virtual void SetHTMLWindowTitle(const wxString& title); virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link); @@ -62,9 +69,11 @@ def run(): virtual wxCursor GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor type) const; """)) + c = module.find('wxHtmlLinkEvent') tools.fixEventClass(c) + c = module.find('wxHtmlCellEvent') tools.fixEventClass(c)