[wxPython-users] Drag n' Drop works different for Unicode and ANSI versions of wxPython

Chris Mellon arkanes at gmail.com
Thu Aug 2 17:27:19 PDT 2007


On 8/2/07, Robin Dunn <robin at alldunn.com> wrote:
> Ophir Horowitz wrote:
> > Hi!
> >
> >
> >
> > I use python2.4 with wxPython 2.8.4.0 Unicode and I have encountered a
> > weird problem with Drag n' Drop.
> >
> > I want to drag texts from my application and drop them on a text box
> > inside a browser.
> >
> > When I wrote this code a weird thing happened: it worked only in Firefox
> > and not in Internet Explorer.
> >
> > Even weirder is the fact that when I uninstalled the wxPython Unicode
> > version and installed the ANSI version, the Drag n' Drop started to work!
> >
> >
> >
> > Of course, this is not a solution, because I need Unicode support in my
> > application…
> >
>
> In the ansi build wx.TextDataObject uses the CF_TEXT data format.  In
> the Unicode build it is CF_UNICODE.  So basically what you are seeing is
> that IE doesn't accept CF_UNICODE formatted objects, which is very silly
> considering MIcrosoft's typical stance on this subject...
>
> There was some talk a few years ago about making it possible to have
> both CF_TEXT and CF_UNICODE objects available from the
> wx.TextDataObject, but I don't think anything was ever done for it.
>
>

There's something more bizarre going on. It accepts unicode paste from
the clipboard, and it accepts unicode drag & drop from a text control
with wx.TE_RICH or from wordpad. However, it doesn't take unicode in
any of the documented text data formats except for CF_TEXT. There's
some hints in the documentation of an RTF format, but it's not
documented anywhere I could find, so that might be it. I tried CF_HTML
on a long shot but it doesn't take that either.

On a side note, there's a potential buffer overflow bug in
wx.PySimpleDataObject. In GetDataHere, it copies the entire value
returned by the Python code into the recieving buffer, but the buffer
might only be as large as GetDataSize bytes. Obviously it would only
happen with buggy code, and I'm not sure if it'd be practical to fix
since you'd need to call back up to Python, but I figured I'm mention
it.




More information about the wxpython-users mailing list