-
Notifications
You must be signed in to change notification settings - Fork 532
8365635: Add MOUSE_DRAG_DONE event type #1873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
8365635: Add MOUSE_DRAG_DONE event type #1873
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. |
@nlisker has indicated that a compatibility and specification (CSR) request is needed for this pull request. @nlisker please create a CSR request for issue JDK-8365635 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
I noticed that the |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Forgot to attach a small manual test application I used for testing full DPR and DnD. Might be helpful for reviewers. package main;
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.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 sourceMouse = createSourceMouse();
var sourceDrag = createSourceDrag();
var target = createTarget();
var scene = createScene(sourceMouse, sourceDrag, target);
stage.setScene(scene);
stage.show();
}
private Rectangle createSourceMouse() {
var sourceMouse = new Rectangle(50, 50);
sourceMouse.setId("sourceMouse");
sourceMouse.setFill(Color.RED);
sourceMouse.setOnDragDetected(e -> {
sourceMouse.startFullDrag();
System.out.println(e.getEventType() + " " + sourceMouse.getId());
e.consume();
});
addDragListeners(sourceMouse);
return sourceMouse;
}
private Rectangle createSourceDrag() {
var sourceDrag = new Rectangle(50, 50);
sourceDrag.setId("sourceDrag");
sourceDrag.setFill(Color.GREEN);
sourceDrag.setOnDragDetected(e -> {
Dragboard db = sourceDrag.startDragAndDrop(TransferMode.ANY);
var content = new ClipboardContent();
content.putString("");
db.setContent(content);
System.out.println(e.getEventType() + " " + sourceDrag.getId());
e.consume();
});
addDragListeners(sourceDrag);
return sourceDrag;
}
private Rectangle createTarget() {
var target = new Rectangle(100, 50);
target.setId("target");
target.setFill(Color.BLUE);
target.setOnDragDetected(MouseEvent::consume);
addDragListeners(target);
return target;
}
private Scene createScene(Rectangle sourceMouse, Rectangle sourceDrag, Rectangle target) {
var scene = new Scene(new VBox(10, new HBox(sourceMouse, sourceDrag), target), 300, 200);
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 addDragListeners(Node node) {
node.setOnDragOver(e -> {
e.acceptTransferModes(TransferMode.ANY);
System.out.println(e.getEventType() + " " + node.getId());
});
node.setOnMouseDragOver(e -> System.out.println(e.getEventType() + " " + node.getId()));
node.setOnDragDropped(e -> {
e.acceptTransferModes(TransferMode.ANY);
e.setDropCompleted(true);
System.out.println(e.getEventType() + " " + node.getId());
});
node.setOnMouseDragReleased(e -> System.out.println(e.getEventType() + " " + node.getId()));
node.setOnDragDone(e -> {
e.acceptTransferModes(TransferMode.ANY);
System.out.println(e.getEventType() + " " + node.getId());
});
node.setOnMouseDragDone(e -> System.out.println(e.getEventType() + " " + node.getId()));
}
} |
return (eventHandlerProperties == null) ? null : eventHandlerProperties.getOnMouseDragDone(); | ||
} | ||
|
||
/// Defines a function to be called when a full press-drag-release gesture ends with this node as its source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the first instance of markdown-style javadoc comments in JavaFX. Do we need a discussion surrounding their use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They were added in JDK 23, which we can use. I don't know if there's anything special to discuss. The JEP gives standard usage examples, which I've followed, so there's no "feature abuse" here either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, they look very different from the other style. Usually matters of style are settled once in a style guide, which we don't have. But I think we should at least consciously agree that we're fine with having two different styles of documentation in the same project. Personally, I value uniformity of style more than the (little) added value that markdown comments bring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 @mstr2 ..
The markdown style is quite different than traditional HTML base style. With increased use of markdown, the comments will look very different. We should keep the uniformity, unless we want to use any feature from markdown style that is not available in traditional style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think markdown style is ok, since it results in a more readable source.
The support in other tools might be lacking initially (for example, Eclipse does not refresh its javadoc pane with markdown as it does with the usual style)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eclipse does not refresh its javadoc pane with markdown as it does with the usual style
Was fixed months ago in eclipse-jdt/eclipse.jdt.ui#2051. Not sure if a stable version was released yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must be doing something wrong - I don't see MouseDragEvent.MOUSE_DRAG_DONE, or in fact MouseDragEvent.ANY sent to the listeners, with this version of the monkey tester:
https://github.com/andy-goryachev-oracle/MonkeyTest/tree/mouse.drag.done
The test page in question is
https://github.com/andy-goryachev-oracle/MonkeyTest/blob/mouse.drag.done/src/com/oracle/tools/fx/monkey/pages/DnDPage.java
return (eventHandlerProperties == null) ? null : eventHandlerProperties.getOnMouseDragDone(); | ||
} | ||
|
||
/// Defines a function to be called when a full press-drag-release gesture ends with this node as its source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think markdown style is ok, since it results in a more readable source.
The support in other tools might be lacking initially (for example, Eclipse does not refresh its javadoc pane with markdown as it does with the usual style)
modules/javafx.graphics/src/main/java/javafx/scene/input/MouseDragEvent.java
Show resolved
Hide resolved
Did you try the sample program I posted? |
no, intentionally. |
In https://github.com/andy-goryachev-oracle/MonkeyTest/blob/mouse.drag.done/src/com/oracle/tools/fx/monkey/pages/DnDPage.java, I don't see you starting a press-drag-release process, only a DnD one. |
Yes, calling
Question: should we explain in greater detail that the new event is coming during full drag only? |
This is only tangentially related, but why in the drag and drop mode the coordinates for DRAG_DONE event are completely bogus when drop happens over a non-accepting target?
|
It's an event type of |
I don't know why it was done this way, but the coordinates are explicitly set to 0 from |
Adds
MOUSE_DRAG_DONE
event type toMouseDragEvent
and appropriate handlers./reviewers 2
/csr
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1873/head:pull/1873
$ git checkout pull/1873
Update a local copy of the PR:
$ git checkout pull/1873
$ git pull https://git.openjdk.org/jfx.git pull/1873/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1873
View PR using the GUI difftool:
$ git pr show -t 1873
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1873.diff
Using Webrev
Link to Webrev Comment