.
Eloquence JDLG contact contact

Documentation / Eloquence JDLG / Drag & drop functionality

Drag & drop functionality

 
.
  Document revision: 2024-05-27
Refers to JDLG version: 2.0.18


Contents


The JDLG drag & drop functionality allows to selectively define which objects may start a drag operation, and what happens when a drop occurs.

The following drag & drop modes are supported:

Dialog-local drag & drop
Submits a rule to the program when a drag & drop operation takes place within the same Dialog.

This enables the program to control the drag & drop action. The involved objects do not perform a default drag & drop action, e.g., an EditText object does not insert the dropped text.

Set the drag attribute to 1 for those objects which should allow to start a dialog-local drag operation (see below).

Set the droprule attribute to nonzero for those objects which should allow a dialog-local drop (see below). This rule value is submitted to the program when a drop on this object occurs.

Both may be set on the same object, e.g., to allow drag & drop within the same ListBox.

Global drag
If global drag is enabled, the object's default drag function may be used to drag content from an object to other programs, e.g., to use drag & drop to copy selected EditText content to an external text editor.

Set the drag attribute to 2 for those objects which should allow to start a global drag operation (see below).

Global drop
By default, editable EditText and ComboBox objects insert dropped text which is dragged from other programs, e.g., when drag & drop is used to copy selected text from an external text editor to an EditText object.

The globaldroprule attribute allows to override this default behavior. In addition, it allows to enable global drop on object classes other than EditText or ComboBox (see below).

If the globaldroprule attribute is set to nonzero, the default drop action does not take place. Instead, the specified rule value is submitted to the program, and the Dialog.dropcontent attribute may be used to obtain the dropped content.

Notes:

  • Requires JDLG version 1.7.5 or newer.

  • To use drag & drop with Java 9 or newer, access to the javax.swing and javax.swing.plaf.basic Java packages must be allowed.

    If you start JDLG using Java Webstart (JNLP), add the java-vm-args attribute to the <j2se ... /> tag, as shown below:

    <j2se version="1.5+"
          java-vm-args="--add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED" />
    

    If you start JDLG using a Java command line, the two --add-opens options below must be specified at the beginning of your command line:

    --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED
    

    Java 9 also supports the --permit-illegal-access command line option which may be used as an alternative to the --add-opens options above. Please note that this option has been replaced with --illegal-access=permit in newer Java versions.

    For example:

    java --permit-illegal-access -jar jdlgS.jar
    java --illegal-access=permit -jar jdlgS.jar
    

  • The provided DRAG-DROP example program demonstrates Dialog-local drag & drop between all supported object classes as well as global drop on the Dialog.


drag : integer, get/set
Enables either dialog-local or global drag:
0 (default) :  Drag is disabled.
1 :  Dialog-local drag is enabled.
2 :  Global drag is enabled.

The drag attribute is implemented for the following object classes:
EditText (see EditText drag & drop attributes below)
ComboBox (see ComboBox drag & drop attributes below)
HtmlView (see HtmlView drag & drop attributes below)
ListBox (see ListBox drop attributes below)
Tree (see Tree drop attributes below)

dragactions : integer, get/set
Specifies the drag actions allowed for dialog-local drag & drop operations.

The dragactions attribute may be set to the sum of the modes below:
1 (default) :  MOVE
2 :  COPY (indicated with a plus-symbol)
4 :  LINK (indicated with a link symbol)

The default drag action is MOVE. The COPY or LINK actions are chosen by holding modifier keys while dragging. Typically, the Ctrl key activates the COPY action, and Ctrl-Shift activates the LINK action.

By default, the MOVE action is allowed only. A program may set dragactions if it wants to react differently depending on the drag action.

Note: The drag attribute must be set to 1 on the same object, otherwise the dragactions attribute has no effect.

droprule : integer, get/set
If nonzero, dialog-local drop is enabled.

When a dialog-local drop occurs, the following happens:

The program may then identify the involved objects and the drop action:

  • The object where the drop occured is identified by the droprule and/or the path returned by DLG DO.

  • DLG GET Dialog.dragfrom returns the path of the object where the drag originated.

  • DLG GET Dialog.dropaction returns the drag & drop action:
    1 :  MOVE
    2 :  COPY
    4 :  LINK

By default, the droprule is zero (dialog-local drop disabled).

The droprule attribute is implemented for the following object classes:
EditText (see EditText drag & drop attributes below)
ComboBox (see ComboBox drag & drop attributes below)
HtmlView (see HtmlView drag & drop attributes below)
ListBox (see ListBox drop attributes below)
Tree (see Tree drop attributes below)

In addition, the droprule attribute may be set for the object container classes Dialog, GroupBox, StatusBar and ToolBar.

Notes:

  • If a droprule is set on a container object, a drop on a child object which does not itself have the droprule attribute set is propagated to the container object. As a consequence, child objects can no longer provide their default drop behavior.

  • The same object may have both the droprule and globaldroprule attributes set, this way accepting both dialog-local and global drop actions, which are then submitted to the program with different rule values.
globaldroprule : integer, get/set
If nonzero, global drop notification is enabled.

When a global drop occurs, the following happens:

The program may then identify the object where the drop occurred, and the content which was dropped as well as the drop action:

  • The object where the drop occured is identified by the globaldroprule and/or the path returned by DLG DO.

  • DLG GET Dialog.dropcontent returns the content which was dropped.

  • DLG GET Dialog.dropaction returns the drag & drop action:
    1 :  MOVE
    2 :  COPY
    4 :  LINK

By default, the globaldroprule is zero (global drop notification disabled).

The globaldroprule attribute is implemented for the following object classes:
EditText (see EditText drag & drop attributes below)
ComboBox (see ComboBox drag & drop attributes below)
HtmlView (see HtmlView drag & drop attributes below)
ListBox (see ListBox drop attributes below)
Tree (see Tree drop attributes below)

In addition, the globaldroprule attribute may be set for the object container classes Dialog, GroupBox, StatusBar and ToolBar.

Notes:

  • If a globaldroprule is set on a container object, a drop on a child object which does not itself have the globaldroprule attribute set is propagated to the container object. As a consequence, child objects can no longer provide their default drop behavior.

  • The same object may have both the droprule and globaldroprule attributes set, this way accepting both dialog-local and global drop actions, which are then submitted to the program with different rule values.


The Dialog drag & drop attributes below are set when a dialog-local drag & drop has happened, or when a global drop has occurred on an object which has the globaldroprule attribute set.

dragfrom : string, get
Path of the object where a dialog-local drag originated.

If a rule submission is not caused by a dialog-local drag & drop, dragfrom is empty.

dropcontent : string, get
Content which was dropped during a global drag & drop on an object which has the globaldroprule attribute set.

If a rule submission is not caused by a global drop, dropcontent is empty.

Notes:

  • The dropped data must be convertible to text, otherwise a global drop is not detected and the globaldroprule is not submitted.

  • Convertible data includes text in a variety of formats, as well as files, e.g., dragged from a file manager or from the Desktop.

  • When a file is dropped, dropcontent contains its absolute path. If multiple files are dropped, the file paths are separated by LF (ASCII 10).
dropaction : integer, get
The drag & drop action associated with a submitted droprule or globaldroprule.
1 :  MOVE
2 :  COPY
4 :  LINK

If a rule submission is not caused by a dialog-local drag & drop or a global drop, dropaction is 0.


The EditText drag & drop attributes below are set when an EditText is involved in a dialog-local drag & drop, or when a global drop has occurred on an EditText which has the globaldroprule attribute set.

dragcontent : string, get
Dragging from an EditText presumes that text is selected.

The dragcontent attribute allows to programmatically query the text selection which was dragged.

If a rule submission is not caused by a dialog-local drag & drop originating from this EditText, dragcontent is empty.

dropcx : integer, get
The column where the drop occurred (starting with 0).

If a rule submission is not caused by a dialog-local or global drop on this EditText, dropcx is -1.

dropcy : integer, get
The line where the drop occurred (starting with 0).

If a rule submission is not caused by a dialog-local or global drop on this EditText, dropcy is -1.


The ComboBox drag & drop attributes below are set when a ComboBox is involved in a dialog-local drag & drop, or when a global drop has occurred on an ComboBox which has the globaldroprule attribute set.

dragcontent : string, get
Dragging from an ComboBox presumes that text is selected.

The dragcontent attribute allows to programmatically query the text selection which was dragged.

If a rule submission is not caused by a dialog-local drag & drop originating from this ComboBox, dragcontent is empty.

dropcx : integer, get
The column where the drop occurred (starting with 0).

If a rule submission is not caused by a dialog-local or global drop on this ComboBox, dropcx is -1.


The HtmlView drag & drop attributes below are set when an HtmlView is involved in a dialog-local drag & drop, or when a global drop has occurred on an HtmlView which has the globaldroprule attribute set.

dragcontent : string, get
Dragging from an HtmlView presumes that text is selected.

The dragcontent attribute allows to programmatically query the text selection which was dragged.

If a rule submission is not caused by a dialog-local drag & drop originating from this HtmlView, dragcontent is empty.

dropcx : integer, get
The column where the drop occurred (starting with 0).

If a rule submission is not caused by a dialog-local or global drop on this HtmlView, dropcx is -1.

Note: The returned value specifies the drop position for plain text documents only, i.e., if mimetype is set to "text/plain".

dropcy : integer, get
The line where the drop occurred (starting with 0).

If a rule submission is not caused by a dialog-local or global drop on this HtmlView, dropcy is -1.

Note: The returned value specifies the drop position for plain text documents only, i.e., if mimetype is set to "text/plain".

dropelement : string, get
If a HTML document is displayed, i.e., if mimetype is set to "text/html", this is set to the id attribute value of the HTML element where the drop occurred.

For example, if a drop occurs on element <div id='July-2016'>, the dropemelent attribute is set to "July-2016".

If a rule submission is not caused by a dialog-local or global drop on this HtmlView, dropelement is empty.


The ListBox drop attributes below are set when a dialog-local drop occurs on a ListBox which has the droprule attribute set, or when a global drop occurs on a ListBox which has the globaldroprule attribute set.

The dropmode attribute below specifies where in a ListBox a drop is allowed to occur.

When a dialog-local drag & drop originates from a ListBox, the following attributes are set: activecolumn, activeitem, activeline and cy.

dropcolumn : integer, get
The column where the drop occurred (starting with 0).

If a rule submission is not caused by a dialog-local or global drop on this ListBox, dropcolumn is -1.

dropline : integer, get
The line where the drop occurred (starting with 1).

If a rule submission is not caused by a dialog-local or global drop on this ListBox, dropline is 0.

dropmode : integer, get/set
Specifies where a drop is allowed to occur.
zero (default) :  Drop is allowed anywhere on a ListBox.
nonzero :  Drop is allowed only on existing ListBox lines.


The Tree drop attributes below are set when a dialog-local drop occurs on a Tree which has the droprule attribute set, or when a global drop occurs on a Tree which has the globaldroprule attribute set.

The dropmode attribute below specifies where in a Tree a drop is allowed to occur.

When a dialog-local drag & drop originates from a Tree, the following attributes are set: activeline and cy.

dropline : integer, get
The node or leaf where the drop occurred (starting with 1).

If a rule submission is not caused by a dialog-local or global drop on this Tree, dropline is 0.

dropmode : integer, get/set
Specifies where a drop is allowed to occur.
zero (default) :  Drop is allowed anywhere on a Tree.
nonzero :  Drop is allowed only on existing Tree entries.


 
 
 
  Privacy | Webmaster | Terms of use | Impressum Revision: 2024-05-27  
  Copyright © 1995-2024 Marxmeier Software AG