我有一个包含四行的TableView,我尝试测试我的拖放实现是否有效。我有以下测试:
TableViewDock table = ...;
//the four rows, using the first cell for the DnD
TableCellItemDock[] rows = {new TableCellItemDock(table.asTable(), 0, 0),
new TableCellItemDock(table.asTable(), 1, 0),
new TableCellItemDock(table.asTable(), 2, 0),
new TableCellItemDock(table.asTable(), 3, 0)};
Wrap target = rows[3].wrap();
rows[0].drag().dnd(target, target.getClickPoint());
但调用dnd
块:我需要手动移动鼠标以“解锁”它并允许拖放操作启动(然后按预期完成)。
让dnd
独立完成工作需要做些什么?
注意:JemmyFX版本= 20120928
答案 0 :(得分:2)
产品中存在问题RT-25057,导致jemmy在某些平台上无法正确使用拖放功能。我现在害怕你需要使用鼠标移动和按下/释放的解决方法:
rows[0].mouse().move();
rows[0].mouse().press();
Point from = rows[0].wrap().getClickPoint();
Point to = target.getClickPoint();
int steps = 10;
for(int i = 1; i<= steps; i++) {
rows[0].mouse().move(new Point(
from.x + i*(to.x - from.x)/steps,
from.y + i*(to.y - from.y)/steps));
}
rows[0].mouse().release();
答案 1 :(得分:1)
感谢谢尔盖,我设法使用以下方法:
protected void dragAndDrop(Wrap<? extends Object> from, Wrap<? extends Object> to) throws InterruptedException {
Point start = scene.wrap().toLocal(from.toAbsolute(from.getClickPoint()));
Point end = scene.wrap().toLocal(to.toAbsolute(to.getClickPoint()));
scene.mouse().move(start);
scene.mouse().press();
scene.mouse().move(end);
scene.mouse().release();
}
我没有像他建议的那样设法用循环进行渐进式移动:当再次调用move
时,代码在第二次迭代时卡住了。