get rid of the built-in drop target in rich text controls before setting the user-defined one as otherwise it fails
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -139,6 +139,10 @@ public:
|
|||||||
|
|
||||||
// Implementation from now on
|
// Implementation from now on
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
|
||||||
|
#if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
|
||||||
|
virtual void SetDropTarget(wxDropTarget *dropTarget);
|
||||||
|
#endif // wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
|
||||||
|
|
||||||
virtual void SetWindowStyleFlag(long style);
|
virtual void SetWindowStyleFlag(long style);
|
||||||
|
|
||||||
|
@@ -77,6 +77,15 @@
|
|||||||
|
|
||||||
#include "wx/msw/missing.h"
|
#include "wx/msw/missing.h"
|
||||||
|
|
||||||
|
#if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
|
||||||
|
|
||||||
|
// dummy value used for m_dropTarget, different from any valid pointer value
|
||||||
|
// (which are all even under Windows) and NULL
|
||||||
|
static wxDropTarget *
|
||||||
|
wxRICHTEXT_DEFAULT_DROPTARGET = wx_reinterpret_cast(wxDropTarget *, 1);
|
||||||
|
|
||||||
|
#endif // wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private classes
|
// private classes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -308,6 +317,20 @@ bool wxTextCtrl::Create(wxWindow *parent,
|
|||||||
if ( !MSWCreateText(value, pos, size) )
|
if ( !MSWCreateText(value, pos, size) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
|
||||||
|
if ( IsRich() )
|
||||||
|
{
|
||||||
|
// rich text controls have a default associated drop target which
|
||||||
|
// allows them to receive (rich) text dropped on them, which is nice,
|
||||||
|
// but prevents us from associating a user-defined drop target with
|
||||||
|
// them as we need to unregister the old one first
|
||||||
|
//
|
||||||
|
// to make it work, we set m_dropTarget to this special value initially
|
||||||
|
// and check for it in our SetDropTarget()
|
||||||
|
m_dropTarget = wxRICHTEXT_DEFAULT_DROPTARGET;
|
||||||
|
}
|
||||||
|
#endif // wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2405,6 +2428,22 @@ bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
return wxTextCtrlBase::MSWOnNotify(idCtrl, lParam, result);
|
return wxTextCtrlBase::MSWOnNotify(idCtrl, lParam, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
|
void wxTextCtrl::SetDropTarget(wxDropTarget *dropTarget)
|
||||||
|
{
|
||||||
|
if ( m_dropTarget == wxRICHTEXT_DEFAULT_DROPTARGET )
|
||||||
|
{
|
||||||
|
// get rid of the built-in drop target
|
||||||
|
::RevokeDragDrop(GetHwnd());
|
||||||
|
m_dropTarget = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxTextCtrlBase::SetDropTarget(dropTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// colour setting for the rich edit controls
|
// colour setting for the rich edit controls
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user