diff --git a/CHANGES.rst b/CHANGES.rst index d6777920..a49ebd1b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -142,6 +142,10 @@ Changes in this release include the following: object from Python to C++. This possible double-deletion and related crashing problems. (#1061) +* Fixed the wrappers for wx.html.HtmlWindow.OnOpeningURL to properly handle the + redirect output parameter. (#1068) This is a backwards-incompatible change, + please see the Migration Guide for details. + diff --git a/demo/HtmlWindow.py b/demo/HtmlWindow.py index fa61be83..36772b06 100644 --- a/demo/HtmlWindow.py +++ b/demo/HtmlWindow.py @@ -39,6 +39,11 @@ class MyHtmlWindow(html.HtmlWindow): self.log.WriteText(' %s\n' % cell.ConvertToText(sel)) return super(MyHtmlWindow, self).OnCellClicked(cell, x, y, evt) + # def OnHTMLOpeningURL(self, urlType, url): + # self.log.WriteText('OnHTMLOpeningURL: %s %s' % (urlType, url)) + # if urlType == wx.html.HTML_URL_IMAGE and 'canada' not in url: + # return (wx.html.HTML_REDIRECT, "bitmaps/canada.gif") + # return (wx.html.HTML_OPEN, "") # This filter doesn't really do anything but show how to use filters diff --git a/docs/MigrationGuide.rst b/docs/MigrationGuide.rst index b3a2d0d9..157757ba 100644 --- a/docs/MigrationGuide.rst +++ b/docs/MigrationGuide.rst @@ -596,6 +596,22 @@ are using Python3 and would like the newest version of PyPubSub then you can drop the version number from the pip command above. +wx.html.HtmlWindow.OnOpeningURL +------------------------------- + +In Classic the return value of ``wx.html.HtmlWindow.OnOpeningURL`` could be +either a value from the ``wx.html.HtmlOpeningStatus`` enumeration, or a string +containing the URL to redirect to. In Phoenix this has been changed to a simpler +wrapper implementation which requires that both an enum value and a string be +returned as a tuple. For example:: + + def OnHTMLOpeningURL(self, urlType, url): + if urlType == wx.html.HTML_URL_IMAGE and url != self.otherURL: + return (wx.html.HTML_REDIRECT, self.otherURL) + return (wx.html.HTML_OPEN, "") + + + .. toctree:: :maxdepth: 2 :hidden: diff --git a/etg/htmlwin.py b/etg/htmlwin.py index e05e78bc..59ca5ec1 100644 --- a/etg/htmlwin.py +++ b/etg/htmlwin.py @@ -34,6 +34,12 @@ def run(): # Tweak the parsed meta objects in the module object as needed for # customizing the generated code and docstrings. + c = module.find('wxHtmlWindowInterface') + assert isinstance(c, etgtools.ClassDef) + c.find('OnHTMLOpeningURL.redirect').out = True + c.find('OnHTMLOpeningURL.redirect').name = 'redirectTo' + + c = module.find('wxHtmlWindow') assert isinstance(c, etgtools.ClassDef) tools.fixWindowClass(c) @@ -47,7 +53,7 @@ def run(): 'OnOpeningURL', 'OnSetTitle', 'OnCellMouseHover', - 'OnCellClicked']: + 'OnCellClicked' ]: c.find(name).isVirtual = True c.find(name).ignore(False) @@ -58,7 +64,7 @@ def run(): virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link); virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type, const wxString& url, - wxString *redirect) const; + wxString *redirectTo /Out/) const; virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell, const wxPoint& pos) const; virtual wxWindow* GetHTMLWindow();