JDK-8307098 : Pressed state gets stuck after drag and drop
  • Type: Bug
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: jfx11,8,jfx17,jfx20,jfx21
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2023-04-25
  • Updated: 2023-04-28
Description
ADDITIONAL SYSTEM INFORMATION :
Seen on both Windows 10 and RHEL 8

A DESCRIPTION OF THE PROBLEM :
The Node#pressed state is maintained as expected if you press and release the mouse over a node. However if that node is an origin of a drag and drop operation the pressed state remains true.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample application. This visualises the pressed state of the circle using red for pressed and black for not pressed. 

Start a drag operation from the circle and then release within the stage outside the circle

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Circle to return to black (pressed = false)
ACTUAL -
Circle remains red (pressed = true)

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class StuckPressedState extends Application {

    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Circle circle = new Circle(100, 100, 20);
        circle.setOnDragDetected(event -> {
            Dragboard db = circle.startDragAndDrop(TransferMode.ANY);
            ClipboardContent clipBoardContent = new ClipboardContent();
            clipBoardContent.putString("foo");
            db.setContent(clipBoardContent);
        });
        circle.pressedProperty().addListener((obs, oldValue, newValue) -> {
            System.out.println("Pressed " + newValue);
            if (Boolean.TRUE.equals(newValue)) {
                circle.setFill(Color.RED);
            } else {
                circle.setFill(Color.BLACK);
            }
        });
        Pane root = new Pane(circle);
        root.setOnDragOver(event -> event.acceptTransferModes(TransferMode.ANY));
        root.setOnDragDropped(event -> {
            System.out.println("Dropped " + event.getDragboard().getContent(DataFormat.PLAIN_TEXT));
            event.setDropCompleted(true);
        });
        root.setPrefSize(200, 200);
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
No known workaround

FREQUENCY : always



Comments
Checked with attached testcase in Windows 10, issue is reproducible, Test Result ========= 8u371: Fail jfx11: Fail jfx17: Fail jfx20: Fail jfx21ea14: Fail
28-04-2023