Drag and drop replacement command(s)?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Drag and drop replacement command(s)?

4D Tech mailing list
Hi all.
I’m upgrading a structure to v18 (Win) and am trying to replace the obsolete command
_O_DRAG AND DROP PROPERTIES($Source_Object_p;$Source_Element_l;$Process_ID_l)
with the v18 equivalent for the purposes of handling drag and drop between two array based list boxes.

An element in either listbox can be dragged to the other listbox and, upon dropping, have the source listbox and dragged element number checked for correctness and processed relevantly.

I have checked the documentation for Language Ref, Deprecated or Removed Features, Pasteboard theme, and KnowledgeBase but can find no explanations or examples anywhere that tell me how to identify the dragged source listbox and element.
I can’t find any v18 demo db that mentions drag and drop in its name.
I’m sure must be an easy way to do it but I just can’t find it.

Can anyone point me in the direction of the info I need to accomplish the equivalent of the old command?
TIA, Keith

PS: I know about the new 4D NUG list but it doesn’t work well on my old Mac and I still see some activity on this one.
**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Drag and drop replacement command(s)?

4D Tech mailing list
Keith,

A better place to ask this sort of question is on the new forum:
https://discuss.4d.com

Alternatively, you can always ask 4D Australasia tech support.

Quoting from the docs:
Since version 11 of 4D, it is recommended to manage drag and drop
operations using the On Begin Drag Over event and the commands of the
Pasteboard theme.
This command is deprecated starting with 4D v17 R4 and should no longer be used.

I used it a lot as well, so it required a bit of reconfiguring.

The best documentation is in the introduction to the topic:
https://doc.4d.com/4Dv18/4D/18/Drag-and-Drop.300-4505037.en.html

Regards,

Wayne



On Sun, 13 Sep 2020 at 14:06, Keith Goebel via 4D_Tech
<[hidden email]> wrote:

>
> Hi all.
> I’m upgrading a structure to v18 (Win) and am trying to replace the obsolete command
> _O_DRAG AND DROP PROPERTIES($Source_Object_p;$Source_Element_l;$Process_ID_l)
> with the v18 equivalent for the purposes of handling drag and drop between two array based list boxes.
>
> An element in either listbox can be dragged to the other listbox and, upon dropping, have the source listbox and dragged element number checked for correctness and processed relevantly.
>
> I have checked the documentation for Language Ref, Deprecated or Removed Features, Pasteboard theme, and KnowledgeBase but can find no explanations or examples anywhere that tell me how to identify the dragged source listbox and element.
> I can’t find any v18 demo db that mentions drag and drop in its name.
> I’m sure must be an easy way to do it but I just can’t find it.
>
> Can anyone point me in the direction of the info I need to accomplish the equivalent of the old command?
> TIA, Keith
>
> PS: I know about the new 4D NUG list but it doesn’t work well on my old Mac and I still see some activity on this one.
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> New Forum: https://discuss.4D.com
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Drag and drop replacement command(s)?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Hi Keith,

Yes, there is a much easier way to handle Drag and Drop.

Use the Pasteboard to pass the drag information from the source form object to the destination form object.

In the "On Begin Drag Over" form event for the source object, create a local object.

Store in that object the information needed to handle the drag.

Then place the object in the pasteboard using:

SET TEXT TO PASTEBOARD (JSON Stringify($theObject))

In the "On drop" form event for the destination object, retrieve the object using:

$theObject := JSON Parse(Get text from pasteboard)

Then perform the data manipulation with the arrays.

TIA, Jeremy


> On Sep 13, 2020, at 12:06 AM, Keith Goebel via 4D_Tech <[hidden email]> wrote:
>
> I’m upgrading a structure to v18 (Win) and am trying to replace the obsolete command
> _O_DRAG AND DROP PROPERTIES($Source_Object_p;$Source_Element_l;$Process_ID_l)
> with the v18 equivalent for the purposes of handling drag and drop between two array based list boxes.
>
> I’m sure must be an easy way to do it but I just can’t find it.
>
> Can anyone point me in the direction of the info I need to accomplish the equivalent of the old command?
> TIA, Keith

**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Drag and drop replacement command(s)?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Thanks to everyone who replied.
Looks like there is no new command to replace the dropped command…

Wayne:
> The best documentation is in the introduction to the topic:
> https://doc.4d.com/4Dv18/4D/18/Drag-and-Drop.300-4505037.en.html

Thanks for your advice.
I have been through that doc many times, thinking I must have missed it, but can find no mention of how to get the drag source variable or dragged element during the On Drop event.
Perhaps I did (and still do) miss it…?

> A better place to ask this sort of question is on the new forum:
> https://discuss.4d.com

Unfortunately it doesn’t work well from my older Mac, and there is no digest version.
There is a summary version but clicking the links doesn’t work without separate login which doesn’t remember the previous login inputs, etc.
I guess I’m being lazy :-)

Jeremy:
> Yes, there is a much easier way to handle Drag and Drop

So, if I am understanding you correctly, we need to replace the command with:
- create an object during On Begin Drag Over (source object)
    - store the source listbox variable (pointer/name?) and its current element in the object (will test if dragged element is known at this point)
- store the stringified object onto text pasteboard
- trap On Drop event for target listbox and extract source info from text pasteboard
    - load JSON object back from text pasteboard
    - extract source listbox (pointer/name?) and dragged element from object
- continue process as usual

Many thanks for pointing out the steps needed.
Seems we will all have to do a lot of recoding to replace a single very simple command that is no longer available. I guess we’ll never know why 4D did that.

Chip:
Thanks for your offer of example code.
Yes please… :-)

Cheers, Keith

> On Sep 13, 2020, at 12:06 AM, Keith Goebel via 4D_Tech <[hidden email]> wrote:
>
> I’m upgrading a structure to v18 (Win) and am trying to replace the obsolete command
> _O_DRAG AND DROP PROPERTIES($Source_Object_p;$Source_Element_l;$Process_ID_l)
> with the v18 equivalent for the purposes of handling drag and drop between two array based list boxes.
>
> I’m sure must be an easy way to do it but I just can’t find it.
>
> Can anyone point me in the direction of the info I need to accomplish the equivalent of the old command?
> TIA, Keith
**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Drag and drop replacement command(s)?

4D Tech mailing list
Keith,
Sorry but I do not really have code that will help you.
My code works with either a selection listbox as source (creates a set), or expects a file/folder from the OS

However, roughly what you need to do:

Note: my memory of this is foggy…and I am guessing a bit here
Since you are using an array listbox as source, as I recall you need to us the on Begin Drag over event to capture the row(s) being dragged and place them on the pasteboard.
Using:
 APPEND DATA TO PASTEBOARD <https://docs.4d.com/4Dv18/4D/18/APPEND-DATA-TO-PASTEBOARD.301-4505401.en.html>
NOTE: As I recall you can create your own data type and then catch it on the drop side

On the drop side Using:
 GET PASTEBOARD DATA TYPE <https://docs.4d.com/4Dv18/4D/18/GET-PASTEBOARD-DATA-TYPE.301-4505393.en.html>                                                                    
You can determine the type of the data on the pasteboard and then using
 GET PASTEBOARD DATA <https://docs.4d.com/4Dv18/4D/18/GET-PASTEBOARD-DATA.301-4505396.en.html>                                                                  

You can retrieve the data, and process it.

Depending on how you are handling the retrieving of the data on the drop side.
You might also need to use:
Pasteboard data size <https://docs.4d.com/4Dv18/4D/18/Pasteboard-data-size.301-4505395.en.html>


I’m sorry but it has been a while since I wrote that code, and I cannot find the source at the moment.
But as I recall this is basically what I did except with a set (since I was working with a section listbox as source).


I hope this helps!
Chip

> On Sep 13, 2020, at 6:35 PM, Keith Goebel via 4D_Tech <[hidden email]> wrote:
>
> Jeremy:
>> Yes, there is a much easier way to handle Drag and Drop
>
> So, if I am understanding you correctly, we need to replace the command with:
> - create an object during On Begin Drag Over (source object)
>    - store the source listbox variable (pointer/name?) and its current element in the object (will test if dragged element is known at this point)
> - store the stringified object onto text pasteboard
> - trap On Drop event for target listbox and extract source info from text pasteboard
>    - load JSON object back from text pasteboard
>    - extract source listbox (pointer/name?) and dragged element from object
> - continue process as usual
>
> Many thanks for pointing out the steps needed.
> Seems we will all have to do a lot of recoding to replace a single very simple command that is no longer available. I guess we’ll never know why 4D did that.
>
> Chip:
> Thanks for your offer of example code.
> Yes please… :-)

**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Drag and drop replacement command(s)?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
On Mon, Sep 14, 2020 at 12:35 AM Keith Goebel via 4D_Tech
<[hidden email]> wrote:
>
> So, if I am understanding you correctly, we need to replace the command with:
> - create an object during On Begin Drag Over (source object)
>     - store the source listbox variable (pointer/name?) and its current element in the object (will test if dragged element is known at this point)
> - store the stringified object onto text pasteboard
> - trap On Drop event for target listbox and extract source info from text pasteboard
>     - load JSON object back from text pasteboard
>     - extract source listbox (pointer/name?) and dragged element from object
> - continue process as usual

It seems complex, but it is not. Pseudocode would look like this:

In sourcce object:

: (Form event code=On Begin Drag Over)
C_BLOB($x)
CLEAR PASTEBOARD
... pack data you want to move to $x
APPEND DATA TO PASTEBOARD("my.unique.signature";$x)

: (Form event code=On Drag Over)
GET PASTEBOARD DATA TYPE($signatures;$nativeTypes;$formatNames)
If (Find in array($nativeTypes;"my.unique.signature")#-1)
  $0:=0  //The drop is accepted
Else
  $0:=-1  //The drag is refused
End if

In target object:

: (Form event code=On Drop)
GET PASTEBOARD DATA TYPE($signatures;$nativeTypes;$formatNames)
If (Find in array($nativeTypes;"ch.prozessTeam.dentalProzess.Mitarbeiter.unused")#-1)
  GET PASTEBOARD DATA("my.unique.signature";$x)
  ... unpack $x into data and insert / do whatever is needed
End if

This is, in fact, much simpler approach - you do not need to care
about process / interprocess D&D, with command SET FILE TO PASTEBOARD
you can D&D to system or other application etc. You can decide from /
to which object data can me dragged by selecting your own signatures,
or do a generic D&D by putting text / files to pasteboard.


--

Peter Bozek
**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Drag and drop replacement command(s)?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
As far as I know, _O_DRAG AND DROP PROPERTIES is depreciated but still works in the latest version of 4D. Putting this off until 4D removes the command is also an option.

John DeSoi, Ph.D.


> On Sep 13, 2020, at 5:35 PM, Keith Goebel via 4D_Tech <[hidden email]> wrote:
>
> Seems we will all have to do a lot of recoding to replace a single very simple command that is no longer available.

**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************