在Android手机上运行应用程序时检测拖动的问题

时间:2019-06-28 11:18:50

标签: gluon-mobile

我目前正在审查如何将应用程序开发迁移到Gluon Mobile。

我当前的测试是拖放的处理。我以为我可以使用普通的JavaFx机制。这就是为什么我将dragDetected的EventHandler添加到CardPaneItem(要在CardPane中显示的项目)的原因。

public CardPaneItem()
{
    super(15);
    .
    .
    .
    //add label in the middle of the hbox
    this.getChildren().addAll(createSpacer(), label, createSpacer());

    this.setOnDragDetected(new EventHandler<MouseEvent>()
    {

        @Override
        public void handle(MouseEvent event) 
        {
            System.out.println("event " + event.getSceneX() + " y " + event.getSceneY());

            Dragboard dragboard = CardPaneItem.this.startDragAndDrop(TransferMode.ANY);
            ClipboardContent content = new ClipboardContent();

            //quick and dirty; changed color of item before the snapshot
            CardPaneItem.this.setStyle("-fx-background-color: #FF0000");
            Image imageSnapshot = CardPaneItem.this.snapshot(null, null);
            //reset color
            CardPaneItem.this.setStyle("");
            dragboard.setDragView(imageSnapshot) ;

            //correction of x; when event in the middle of the item...not all, not finished
            double wVerschiebung = imageSnapshot.getWidth() - event.getSceneX();


            dragboard.setDragViewOffsetX(wVerschiebung);
            dragboard.setDragViewOffsetY(0);
            content.putString("TEST DRAG");
            dragboard.setContent(content);
            //event.consume();

        }

    });
}

仅当在计算机上进行测试时,此过程才有效。安装在Android手机上,处理程序无响应。

是否有关于如何在Gluon Mobile上利用拖放功能的文档?

Link进入完整的测试项目。

0 个答案:

没有答案