8389551: Update class docs of MouseEvent - #2238
Open
nlisker wants to merge 1 commit into
Open
Conversation
|
👋 Welcome back nlisker! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Collaborator
Author
|
Notes to reviewers:
import javafx.application.Application;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.InputEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class MouseTest extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(@SuppressWarnings("exports") Stage stage) throws Exception {
var scene = createScene(createSourcePDR(), createSourceMouseFullPDR(), createSourceDnD(), createTarget());
stage.setScene(scene);
stage.show();
}
private Rectangle createSourcePDR() {
var source = new Rectangle(50, 50);
source.setId("PDR");
source.setFill(Color.YELLOW);
source.setOnDragDetected(e -> {
print(source, e);
e.consume();
});
addCommonListeners(source);
return source;
}
private Rectangle createSourceMouseFullPDR() {
var source = new Rectangle(50, 50);
source.setId("FullPDR");
source.setFill(Color.RED);
source.setOnDragDetected(e -> {
source.startFullDrag();
print(source, e);
e.consume();
});
addCommonListeners(source);
return source;
}
private Rectangle createSourceDnD() {
var source = new Rectangle(50, 50);
source.setId("DnD");
source.setFill(Color.GREEN);
source.setOnDragDetected(e -> {
Dragboard db = source.startDragAndDrop(TransferMode.ANY);
var content = new ClipboardContent();
content.putString("");
db.setContent(content);
print(source, e);
e.consume();
});
addCommonListeners(source);
return source;
}
private Rectangle createTarget() {
var target = new Rectangle(100, 50);
target.setId("target");
target.setFill(Color.BLUE);
target.setOnDragDetected(MouseEvent::consume);
addCommonListeners(target);
return target;
}
private Scene createScene(Rectangle sourcePDR, Rectangle sourceFullPDR, Rectangle sourceDrag, Rectangle target) {
var scene = new Scene(new VBox(10, new HBox(sourcePDR, sourceFullPDR, sourceDrag), target), 300, 200);
scene.setOnMouseEntered(e -> System.out.println(e.getEventType() + " scene"));
scene.setOnMouseExited(e -> System.out.println(e.getEventType() + " scene"));
scene.setOnDragDetected(e -> {
scene.startFullDrag();
System.out.println(e.getEventType() + " scene");
});
scene.setOnDragDone(e -> {
e.acceptTransferModes(TransferMode.ANY);
System.out.println(e.getEventType() + " scene");
});
scene.setOnMouseDragReleased(e -> System.out.println(e.getEventType() + " scene"));
scene.setOnMouseDragDone(e -> System.out.println(e.getEventType() + " scene"));
return scene;
}
private static void addCommonListeners(Node node) {
// MouseEvent
node.setOnMouseMoved(e -> print(node, e));
node.setOnMouseDragged(e -> print(node, e));
node.setOnMouseEntered(e -> print(node, e));
node.setOnMouseExited(e -> print(node, e));
node.setOnMouseReleased(e -> print(node, e));
node.setOnMouseClicked(e -> print(node, e));
node.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, e -> {
System.out.print("TARGET_ ");
print(node, e);
});
// MouseDragEvent
node.setOnMouseDragOver(e -> print(node, e));
node.setOnMouseDragEntered(e -> print(node, e));
node.setOnMouseDragExited(e -> print(node, e));
node.setOnMouseDragReleased(e -> print(node, e));
node.setOnMouseDragDone(e -> System.out.println(e.getEventType() + " " + node.getId()));
// DragEvent
node.setOnDragOver(e -> {
e.acceptTransferModes(TransferMode.ANY);
print(node, e);
});
node.setOnDragEntered(e -> {
e.acceptTransferModes(TransferMode.ANY);
print(node, e);
});
node.setOnDragExited(e -> {
print(node, e);
});
node.setOnDragDropped(e -> {
e.acceptTransferModes(TransferMode.ANY);
e.setDropCompleted(true);
print(node, e);
});
node.setOnDragDone(e -> {
e.acceptTransferModes(TransferMode.ANY);
print(node, e);
});
}
private static void print(Node node, InputEvent e) {
System.out.println(e.getEventType() + " " + node.getId());
}
} |
nlisker
marked this pull request as ready for review
August 1, 2026 01:12
Collaborator
Author
|
/reviewers 2 @andy-goryachev-oracle @kevinrushforth please review. This is a docs-only change that can go into 27. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a section for button events and clarifies the existing sections.
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2238/head:pull/2238$ git checkout pull/2238Update a local copy of the PR:
$ git checkout pull/2238$ git pull https://git.openjdk.org/jfx.git pull/2238/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2238View PR using the GUI difftool:
$ git pr show -t 2238Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2238.diff
Using Webrev
Link to Webrev Comment