-
Bug
-
Resolution: Duplicate
-
P3
-
jfx12
-
x86
-
linux
ADDITIONAL SYSTEM INFORMATION :
Linux Ubuntu latest version and any other Linux
A DESCRIPTION OF THE PROBLEM :
I use canvas.setOnDragOver((ev)->... ) to intercept any drag event over a canvas. The canvas is repainted on each event. In Windows the behaviour is correct, and triggered on each mouse move.
On Linux this is triggered only one time.
I provide below a test class. Run it on Windows and try to drag the mouse over the text, you will get a bunch of messages 'Drag over'.
Do the same on Linux and you will get only one time the same message.
Second, there is in the code a line db.setDragView(), commented.
Uncomment it and make sure is pointing to a small image on disk.
Running the code on Linux you will get an exception like:
(java:5559): GLib-GObject-WARNING **: 08:10:27.208: ../../../../gobject/gsignal.c:2523: signal 'expose-event' is invalid for instance '0x7fac3014e520' of type 'GtkWindow'
This works fine in Windows.
REGRESSION : Last worked in version 12
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class SampleRenderingIssue extends Application {
private final StackPane root = new StackPane();
private final Scene scene = new Scene(root, 300, 250);
private final BorderPane pane = new BorderPane();
private final Canvas canvas = new Canvas();
@Override
public void start(Stage stage) {
stage.setTitle("Sample Canvas");
HBox vbox = new HBox();
HBox.setHgrow(pane, Priority.ALWAYS);
vbox.getChildren().addAll( /*createTreeView(),*/ pane );
pane.getChildren().add(canvas);
root.getChildren().add(vbox);
//scene.getStylesheets().add( SampleRenderingIssue.class.getResource("resources/dark.css").toExternalForm());
stage.setScene(scene);
stage.sizeToScene();
setupCanvasPane();
stage.show();
Platform.runLater(()-> paint());
}
private void setupCanvasPane(){
canvas.widthProperty().bind(pane.widthProperty());
canvas.heightProperty().bind(pane.heightProperty());
canvas.setOnDragDetected((ev)-> {System.out.println("Drag detected"); final ClipboardContent content = new ClipboardContent();
final Dragboard db = canvas.startDragAndDrop(TransferMode.COPY);
//db.setDragView(Resources.getImage("fk.png"));
content.put(DataFormat.PLAIN_TEXT, 1);
db.setContent(content);
ev.consume();});
canvas.setOnDragOver((ev)-> {System.out.println("Drag over"); ev.consume();});
canvas.setOnDragDropped((ev)-> {System.out.println("Drag end"); ev.consume();});
canvas.setOnDragDone((ev)-> {System.out.println("Drag done"); ev.consume();});
pane.widthProperty().addListener((o,p,c)-> paint());
paint();
}
public void paint(){
GraphicsContext gr = canvas.getGraphicsContext2D();
gr.clearRect( 0,0, canvas.getWidth(), canvas.getHeight() );
gr.setFill( Color.web("#ffffff") );
gr.fillRect( 0,0,canvas.getWidth(), canvas.getHeight());
gr.setFont( Font.font( "Monospaced"));
gr.setFill( Color.web("#e39d62") );
gr.fillText("SELECT * FROM", 50, 70 );
gr.setFill( Color.WHITE );
gr.fillText("sample_table", 50, 88 );
}
public static void main(String[] args) {
launch(args);
}
}
FREQUENCY : always
Linux Ubuntu latest version and any other Linux
A DESCRIPTION OF THE PROBLEM :
I use canvas.setOnDragOver((ev)->... ) to intercept any drag event over a canvas. The canvas is repainted on each event. In Windows the behaviour is correct, and triggered on each mouse move.
On Linux this is triggered only one time.
I provide below a test class. Run it on Windows and try to drag the mouse over the text, you will get a bunch of messages 'Drag over'.
Do the same on Linux and you will get only one time the same message.
Second, there is in the code a line db.setDragView(), commented.
Uncomment it and make sure is pointing to a small image on disk.
Running the code on Linux you will get an exception like:
(java:5559): GLib-GObject-WARNING **: 08:10:27.208: ../../../../gobject/gsignal.c:2523: signal 'expose-event' is invalid for instance '0x7fac3014e520' of type 'GtkWindow'
This works fine in Windows.
REGRESSION : Last worked in version 12
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class SampleRenderingIssue extends Application {
private final StackPane root = new StackPane();
private final Scene scene = new Scene(root, 300, 250);
private final BorderPane pane = new BorderPane();
private final Canvas canvas = new Canvas();
@Override
public void start(Stage stage) {
stage.setTitle("Sample Canvas");
HBox vbox = new HBox();
HBox.setHgrow(pane, Priority.ALWAYS);
vbox.getChildren().addAll( /*createTreeView(),*/ pane );
pane.getChildren().add(canvas);
root.getChildren().add(vbox);
//scene.getStylesheets().add( SampleRenderingIssue.class.getResource("resources/dark.css").toExternalForm());
stage.setScene(scene);
stage.sizeToScene();
setupCanvasPane();
stage.show();
Platform.runLater(()-> paint());
}
private void setupCanvasPane(){
canvas.widthProperty().bind(pane.widthProperty());
canvas.heightProperty().bind(pane.heightProperty());
canvas.setOnDragDetected((ev)-> {System.out.println("Drag detected"); final ClipboardContent content = new ClipboardContent();
final Dragboard db = canvas.startDragAndDrop(TransferMode.COPY);
//db.setDragView(Resources.getImage("fk.png"));
content.put(DataFormat.PLAIN_TEXT, 1);
db.setContent(content);
ev.consume();});
canvas.setOnDragOver((ev)-> {System.out.println("Drag over"); ev.consume();});
canvas.setOnDragDropped((ev)-> {System.out.println("Drag end"); ev.consume();});
canvas.setOnDragDone((ev)-> {System.out.println("Drag done"); ev.consume();});
pane.widthProperty().addListener((o,p,c)-> paint());
paint();
}
public void paint(){
GraphicsContext gr = canvas.getGraphicsContext2D();
gr.clearRect( 0,0, canvas.getWidth(), canvas.getHeight() );
gr.setFill( Color.web("#ffffff") );
gr.fillRect( 0,0,canvas.getWidth(), canvas.getHeight());
gr.setFont( Font.font( "Monospaced"));
gr.setFill( Color.web("#e39d62") );
gr.fillText("SELECT * FROM", 50, 70 );
gr.setFill( Color.WHITE );
gr.fillText("sample_table", 50, 88 );
}
public static void main(String[] args) {
launch(args);
}
}
FREQUENCY : always