Project

General

Profile

Bug #9589

Wt does not always show the indicator between the rows if dropping on an item is also allowed.

Added by Andreas Frolov 11 months ago. Updated 10 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
01/07/2022
Due date:
% Done:

0%

Estimated time:

Description

Feature #8636 https://redmine.webtoolkit.eu/issues/8636 is not usable well.

If both drop locations (Wt::DropLocation::OnItem and Wt::DropLocation::BetweenRows) are allowed in view, a drop indicator is displayed between items in tree view only if the mouse cursor with the drop object is in the decoration area (to the left of items). In the table view in this case it is only possible to drop after the last item.

Small example so that you can test it quickly:

auto layout = std::make_unique<Wt::WHBoxLayout>();

int rowCount = 10;

auto model1 = std::make_shared<Wt::WStandardItemModel>(rowCount, 1);
for (int i = 0; i < rowCount; ++i)
{
    model1->setData(model1->index(i, 0), std::string("Model 1 item ") + std::to_string(i));
    auto item = model1->item(i);
    item->setFlags(item->flags() | Wt::ItemFlag::DragEnabled | Wt::ItemFlag::DropEnabled);
}

auto view1 = layout->addWidget(std::make_unique<Wt::WTreeView>());
view1->setModel(model1);
view1->setSelectionMode(Wt::SelectionMode::Single);
view1->setDragEnabled(true);
view1->setDropsEnabled(true);
view1->setEnabledDropLocations(Wt::DropLocation::OnItem | Wt::DropLocation::BetweenRows);

auto model2 = std::make_shared<Wt::WStandardItemModel>(rowCount, 1);
for (int i = 0; i < rowCount; ++i)
{
    model2->setData(model2->index(i, 0), std::string("Model 2 item ") + std::to_string(i));
    auto item = model2->item(i);
    item->setFlags(item->flags() | Wt::ItemFlag::DragEnabled | Wt::ItemFlag::DropEnabled);
}

auto view2 = layout->addWidget(std::make_unique<Wt::WTableView>());
view2->setModel(model2);
view2->setSelectionMode(Wt::SelectionMode::Single);
view2->setDragEnabled(true);
view2->setDropsEnabled(true);
view2->setEnabledDropLocations(Wt::DropLocation::OnItem | Wt::DropLocation::BetweenRows);

Also available in: Atom PDF