Re: Move & Copy DnD operation on OS-X and Linux

2016-03-29 Thread Tom Schindl
Done as https://bugs.openjdk.java.net/browse/JDK-8153032

Tom

On 29.03.16 22:19, David Hill wrote:
> On 3/29/16, 7:04 AM, Tom Schindl wrote:
>> Hi,
> Tom,
>This is something we might be able to change in 9.
> Would you file a bug for this ?
> 
> thanks,
>Dave
>>
>> While developing our editor control we tried to implement DnD of
>> Text-Selection to:
>> * to rearrange text inside the control
>> * to copy text selections to another position inside the text
>>
>> On Win32 everything works as expected, if you start dragging the initial
>> operation is MOVE and you can change that to a COPY by pressing CTRL
>> while dragging.
>>
>> On Linux the initial gesture is COPY which is not how DnD works in
>> things like nautilus, ... . I can get that to change to a move operation
>> by holding the SHIFT key.
>>
>> On OS-X the initial gesture is a COPY and which is not how DnD works
>> finder or eg Finder, and I haven't found a way to change the operation
>> to a MOVE.
>>
>> I would expect the following on ALL operation systems:
>> - a drag WITHOUT any modifier key is a MOVE operation
>>
>> - on Windows&  Linux I make it to a copy operation by pressing CTRL
>>while dragging
>>
>> - on OS-X I make it a copy operation by pressing ALT while dragging
>>
>> In general I think the problem is even bigger because the default
>> operation depends on the target eg on windows when you drag a file
>> between 2 folders on the same filesystem you get a default MOVE but if
>> you drag to another one the default is a COPY and SHIFT makes it a MOVE.
>>
>> JavaFX does all that right but what it gets wrong is the default
>> operation. Any thoughts on this? Did we miss something obvious?
>>
>> The simple application below is how to reproduce.
>>
>>> package application;
>>>
>>>
>>> import javafx.application.Application;
>>> import javafx.scene.Scene;
>>> import javafx.scene.input.ClipboardContent;
>>> import javafx.scene.input.DataFormat;
>>> import javafx.scene.input.DragEvent;
>>> import javafx.scene.input.Dragboard;
>>> import javafx.scene.input.MouseEvent;
>>> import javafx.scene.input.TransferMode;
>>> import javafx.scene.layout.BorderPane;
>>> import javafx.stage.Stage;
>>>
>>>
>>> public class Main extends Application {
>>>
>>> private BorderPane root;
>>> @Override
>>> public void start(Stage primaryStage) {
>>> try {
>>> root = new BorderPane();
>>> Scene scene = new Scene(root,400,400);
>>>
>>> scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
>>>
>>> primaryStage.setScene(scene);
>>> primaryStage.show();
>>>
>>> root.setOnDragDetected(this::onDragDetected);
>>> root.setOnDragOver(this::onDragOver);
>>> root.setOnDragDropped(this::onDragDropped);
>>> root.setOnDragDone(this::onDragDone);
>>>
>>> } catch(Exception e) {
>>> e.printStackTrace();
>>> }
>>> }
>>>
>>> public static void main(String[] args) {
>>> launch(args);
>>> }
>>>
>>> private final DataFormat f = new DataFormat() {
>>> };
>>>
>>> private void onDragDetected(MouseEvent event) {
>>> System.err.println(this + " onDragDetected");
>>> Dragboard db = root.startDragAndDrop(TransferMode.ANY);
>>>
>>> ClipboardContent c = new ClipboardContent();
>>> c.putString("Hello world");
>>> db.setContent(c);
>>> event.consume();
>>> }
>>>
>>> private void onDragOver(DragEvent event) {
>>> event.getTransferMode();
>>> event.acceptTransferModes(TransferMode.ANY);
>>> System.err.println(event.getTransferMode());
>>> //System.err.println("onDragOver " +
>>> event.getAcceptedTransferMode());
>>> event.consume();
>>> }
>>>
>>> private void onDragDropped(DragEvent event) {
>>> System.err.println(this + " onDragDropped " +
>>> event.getAcceptedTransferMode());
>>> event.setDropCompleted(true);
>>> event.consume();
>>> }
>>>
>>> private void onDragDone(DragEvent event) {
>>> System.err.println(this + " onDragDone "  +
>>> event.getAcceptedTransferMode());
>>> System.err.println("payload: " +
>>> event.getDragboard().getString());
>>> event.consume();
>>> }
>>> }
>>
>>
> 
> 


-- 
Thomas Schindl, CTO
BestSolution.at EDV Systemhaus GmbH
Eduard-Bodem-Gasse 5-7, A-6020 Innsbruck
http://www.bestsolution.at/
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck


Re: Move & Copy DnD operation on OS-X and Linux

2016-03-29 Thread David Hill

On 3/29/16, 7:04 AM, Tom Schindl wrote:

Hi,

Tom,
   This is something we might be able to change in 9.
Would you file a bug for this ?

thanks,
   Dave


While developing our editor control we tried to implement DnD of
Text-Selection to:
* to rearrange text inside the control
* to copy text selections to another position inside the text

On Win32 everything works as expected, if you start dragging the initial
operation is MOVE and you can change that to a COPY by pressing CTRL
while dragging.

On Linux the initial gesture is COPY which is not how DnD works in
things like nautilus, ... . I can get that to change to a move operation
by holding the SHIFT key.

On OS-X the initial gesture is a COPY and which is not how DnD works
finder or eg Finder, and I haven't found a way to change the operation
to a MOVE.

I would expect the following on ALL operation systems:
- a drag WITHOUT any modifier key is a MOVE operation

- on Windows&  Linux I make it to a copy operation by pressing CTRL
   while dragging

- on OS-X I make it a copy operation by pressing ALT while dragging

In general I think the problem is even bigger because the default
operation depends on the target eg on windows when you drag a file
between 2 folders on the same filesystem you get a default MOVE but if
you drag to another one the default is a COPY and SHIFT makes it a MOVE.

JavaFX does all that right but what it gets wrong is the default
operation. Any thoughts on this? Did we miss something obvious?

The simple application below is how to reproduce.


package application;


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.DragEvent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;


public class Main extends Application {

private BorderPane root;
@Override
public void start(Stage primaryStage) {
try {
root = new BorderPane();
Scene scene = new Scene(root,400,400);

scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();

root.setOnDragDetected(this::onDragDetected);
root.setOnDragOver(this::onDragOver);
root.setOnDragDropped(this::onDragDropped);
root.setOnDragDone(this::onDragDone);

} catch(Exception e) {
e.printStackTrace();
}
}

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

private final DataFormat f = new DataFormat() {
};

private void onDragDetected(MouseEvent event) {
System.err.println(this + " onDragDetected");
Dragboard db = root.startDragAndDrop(TransferMode.ANY);

ClipboardContent c = new ClipboardContent();
c.putString("Hello world");
db.setContent(c);
event.consume();
}

private void onDragOver(DragEvent event) {
event.getTransferMode();
event.acceptTransferModes(TransferMode.ANY);
System.err.println(event.getTransferMode());
//  System.err.println("onDragOver " + 
event.getAcceptedTransferMode());
event.consume();
}

private void onDragDropped(DragEvent event) {
System.err.println(this + " onDragDropped " + 
event.getAcceptedTransferMode());
event.setDropCompleted(true);
event.consume();
}

private void onDragDone(DragEvent event) {
System.err.println(this + " onDragDone "  + 
event.getAcceptedTransferMode());
System.err.println("payload: " + 
event.getDragboard().getString());
event.consume();
}
}






--
David Hill
Java Embedded Development

"A man's feet should be planted in his country, but his eyes should survey the 
world."
-- George Santayana (1863 - 1952)