JPro-one / JPro

The right place to report about bugs or suggest improvements for JPro.
https://www.jpro.one
9 stars 4 forks source link

Dragboard setDragView() don't show ghost image while dragging(2019.2.5) #69

Open jigarjigjig opened 4 years ago

jigarjigjig commented 4 years ago

source.setOnDragDetected(new EventHandler() { public void handle(MouseEvent event) {

            if (dragEventObject.longPress == true) {
                source.startFullDrag();
                Dragboard db = source.startDragAndDrop(TransferMode.MOVE);
                ClipboardContent content = new ClipboardContent();
                content.putString("hello");
                db.setContent(content);

                /*SnapshotParameters snapShotparams = new SnapshotParameters();
                snapShotparams.setFill(Color.TRANSPARENT);
                WritableImage temp = source.snapshot(snapShotparams,
                        new WritableImage((int) source.getPrefWidth(),
                                (int) source.getPrefHeight()));
                ImageView tempImage = new ImageView(temp);
                db.setDragView(tempImage.getImage());*/

                BufferedImage dummyBuffer = new BufferedImage(100, 40,BufferedImage.TRANSLUCENT);
                Graphics2D graphics = dummyBuffer.createGraphics();
                java.awt.Color rgb = new java.awt.Color(255, 0, 0);
                graphics.setColor (rgb);
                graphics.fillRect ( 0, 0, 100, 40);
                graphics.dispose();

                //CustomImageViewWithUrl customImageViewWithUrl = new CustomImageViewWithUrl(ComponentType.getURL(0), 50, 50);

                Image image = SwingFXUtils.toFXImage(dummyBuffer, null);

                //Image image = new Image(ComponentType.getURL(0));

                ImageView tempImage = new ImageView(image);

                db.setDragView(tempImage.getImage());
            }
FlorianKirmaier commented 4 years ago

We are looking into it. This is something which is supposed to work. The snapshot should also work (with javafx11) But probably there is a regression related to the DragImage.

jigarjigjig commented 4 years ago

Tried with javafx 11 but still not working [info] c.j.i.s.Initializer$ - OS: Mac OS X [info] c.j.i.s.Initializer$ - JPro: 2019.2.6 [info] c.j.i.s.Initializer$ - Java version: 11.0.2 [info] c.j.i.s.Initializer$ - JVM: 11.0.2 Oracle Corporation [info] c.j.i.s.Initializer$ - JavaFX version: 11.0.3.4-jpro+0-2019-12-20-172819

dependencies { classpath 'com.sandec.jpro:jpro-plugin-gradle:2019.2.6' } compile "org.openjfx:javafx-base:14:$platform" compile "org.openjfx:javafx-graphics:14:$platform" compile "org.openjfx:javafx-controls:14:$platform" compile "org.openjfx:javafx-swing:14:$platform" compile "org.openjfx:javafx-fxml:14:$platform" compile "org.openjfx:javafx-media:14:$platform" compile "org.openjfx:javafx-web:14:$platform"

FlorianKirmaier commented 4 years ago

After some investigation we found out why this is not working by default.

You can set the property noRenderJobs=false in gradle or maven plugin. On Java(FX)11 then the application will allow rendering of snapshots. On Java8 it will massively slow down the application, which is why it's not deactivated by default.

With the next major release, we will probably remove support for Java8 and support snapshots by default.