ui::DragEventArgs¶
Header: winui/ui/DragDrop.hpp.
What a drop target is told as a drag moves over it and ends on it.
Passed to Element::drag_enter(), drag_over(), drag_leave() and drop(), and to the handlers set with Element::on_drag_over() and the others. drag_over() answers with a DragResponse.
Example:
std::vector<std::size_t> favorites;
auto target = std::make_unique<ui::BorderControl>();
target->set_allow_drop(true);
target->on_drag_over([](const ui::DragEventArgs& e)
{
if (!std::any_cast<std::size_t>(&e.data.data))
{
return ui::DragResponse{}; // not a row: refused
}
return ui::DragResponse{.operation = ui::DataPackageOperation::Copy, .caption = "Add to favorites"};
});
target->on_drop([&](const ui::DragEventArgs& e)
{
favorites.push_back(std::any_cast<std::size_t>(e.data.data));
});
| Field | Type | Default | |
|---|---|---|---|
data |
const DataPackage& |
The package being dragged; owned by the drag, valid for this call only. | |
position |
Point |
The pointer, in window coordinates. |