1 \section{\class{wxDropTarget
}}\label{wxdroptarget
}
3 This class represents a target for a drag and drop operation. A
\helpref{wxDataObject
}{wxdataobject
}
4 can be associated with it and by default, this object will be filled with the data from the
5 drag source, if the data formats supported by the data object match the drag source data
8 There are various virtual handler functions defined in this class which may be overridden
9 to give visual feedback or react in a more fine-tuned way, e.g. by not accepting data on
10 the whole window area, but only a small portion of it. The normal sequence of calls is
11 \helpref{OnEnter
}{wxdroptargetonenter
}, possibly many times
\helpref{OnDragOver
}{wxdroptargetondragover
},
12 \helpref{OnDrop
}{wxdroptargetondrop
} and finally
\helpref{OnData
}{wxdroptargetondata
}.
14 See
\helpref{Drag and drop overview
}{wxdndoverview
} and
\helpref{wxDataObject overview
}{wxdataobjectoverview
}
17 \wxheading{Derived from
}
21 \wxheading{Include files
}
27 \helpref{wxCore
}{librarieslist
}
31 \index{wxDragResult
}wxDragResult is defined as follows:
36 wxDragError, // error prevented the d&d operation from completing
37 wxDragNone, // drag target didn't accept the data
38 wxDragCopy, // the data was successfully copied
39 wxDragMove, // the data was successfully moved (MSW only)
40 wxDragLink, // operation is a drag-link
41 wxDragCancel // the operation was cancelled by user (not an error)
47 \helpref{wxDropSource
}{wxdropsource
},
48 \helpref{wxTextDropTarget
}{wxtextdroptarget
},
\helpref{wxFileDropTarget
}{wxfiledroptarget
},
49 \helpref{wxDataFormat
}{wxdataformat
},
\helpref{wxDataObject
}{wxdataobject
}
51 \latexignore{\rtfignore{\wxheading{Members
}}}
53 \membersection{wxDropTarget::wxDropTarget
}\label{wxdroptargetwxdroptarget
}
55 \func{}{wxDropTarget
}{\param{wxDataObject*
}{ data = NULL
}}
57 Constructor.
{\it data
} is the data to be associated with the drop target.
59 \membersection{wxDropTarget::
\destruct{wxDropTarget
}}\label{wxdroptargetdtor
}
61 \func{}{\destruct{wxDropTarget
}}{\void}
63 Destructor. Deletes the associated data object, if any.
65 \membersection{wxDropTarget::GetData
}\label{wxdroptargetgetdata
}
67 \func{virtual void
}{GetData
}{\void}
69 This method may only be called from within
\helpref{OnData
}{wxdroptargetondata
}.
70 By default, this method copies the data from the drop source to the
71 \helpref{wxDataObject
}{wxdataobject
} associated with this drop target,
72 calling its
\helpref{wxDataObject::SetData
}{wxdataobjectsetdata
} method.
74 \membersection{wxDropTarget::OnData
}\label{wxdroptargetondata
}
76 \func{virtual wxDragResult
}{OnData
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxDragResult
}{ def
}}
78 Called after
\helpref{OnDrop
}{wxdroptargetondrop
} returns true. By default this
79 will usually
\helpref{GetData
}{wxdroptargetgetdata
} and will return the suggested
80 default value
{\it def
}.
82 \membersection{wxDropTarget::OnDrop
}\label{wxdroptargetondrop
}
84 \func{virtual bool
}{OnDrop
}{\param{wxCoord
}{x
},
\param{wxCoord
}{y
}}
86 Called when the user drops a data object on the target. Return false to veto the operation.
88 \wxheading{Parameters
}
90 \docparam{x
}{The x coordinate of the mouse.
}
92 \docparam{y
}{The y coordinate of the mouse.
}
94 \wxheading{Return value
}
96 Return true to accept the data, false to veto the operation.
98 \membersection{wxDropTarget::OnEnter
}\label{wxdroptargetonenter
}
100 \func{virtual wxDragResult
}{OnEnter
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxDragResult
}{ def
}}
102 Called when the mouse enters the drop target. By default, this calls
\helpref{OnDragOver
}{wxdroptargetondragover
}.
104 \wxheading{Parameters
}
106 \docparam{x
}{The x coordinate of the mouse.
}
108 \docparam{y
}{The y coordinate of the mouse.
}
110 \docparam{def
}{Suggested default for return value. Determined by SHIFT or CONTROL key states.
}
112 \wxheading{Return value
}
114 Returns the desired operation or
{\tt wxDragNone
}. This is used for optical feedback
115 from the side of the drop source, typically in form of changing the icon.
117 \membersection{wxDropTarget::OnDragOver
}\label{wxdroptargetondragover
}
119 \func{virtual wxDragResult
}{OnDragOver
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxDragResult
}{ def
}}
121 Called when the mouse is being dragged over the drop target. By default,
122 this calls functions return the suggested return value
{\it def
}.
124 \wxheading{Parameters
}
126 \docparam{x
}{The x coordinate of the mouse.
}
128 \docparam{y
}{The y coordinate of the mouse.
}
130 \docparam{def
}{Suggested value for return value. Determined by SHIFT or CONTROL key states.
}
132 \wxheading{Return value
}
134 Returns the desired operation or
{\tt wxDragNone
}. This is used for optical feedback
135 from the side of the drop source, typically in form of changing the icon.
137 \membersection{wxDropTarget::OnLeave
}\label{wxdroptargetonleave
}
139 \func{virtual void
}{OnLeave
}{\void}
141 Called when the mouse leaves the drop target.
143 \membersection{wxDropTarget::SetDataObject
}\label{wxdroptargetsetdataobject
}
145 \func{void
}{SetDataObject
}{\param{wxDataObject*
}{ data
}}
147 Sets the data
\helpref{wxDataObject
}{wxdataobject
} associated with the
148 drop target and deletes any previously associated data object.