Drag from outside of 4D into a 4D Form

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

Drag from outside of 4D into a 4D Form

4D Tech mailing list
I thought it would be good for an Import to let people drag a file from the desktop onto a form. It certainly is not a critical feature, the old style select from a file dialog works good for me.

I was looking for an example database, or tech note but could not find one. The Drag and Drop Properties is not giving me any information with which to accept or decline the on drag over.

I have done lots of drag and drop within the same form before. So I am somewhat familiar with the concept, and phases.

Any pointers appreciated.

Jody Bevan
Developer

Argus Productions Inc. <https://www.facebook.com/ArgusProductions/>
+1 587-487-6120



**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
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 from outside of 4D into a 4D Form

4D Tech mailing list


> On Jun 4, 2018, at 5:32 PM, Jody Bevan via 4D_Tech <[hidden email]> wrote:
>
> I thought it would be good for an Import to let people drag a file from the desktop onto a form. It certainly is not a critical feature, the old style select from a file dialog works good for me.
>
> I was looking for an example database, or tech note but could not find one. The Drag and Drop Properties is not giving me any information with which to accept or decline the on drag over.
>
> I have done lots of drag and drop within the same form before. So I am somewhat familiar with the concept, and phases.
>
> Any pointers appreciated.
>

Hi Jody,

I think this might help:

http://kb.4d.com/assetid=76344 <http://kb.4d.com/assetid=76344>

Regards,

Milan


**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
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 from outside of 4D into a 4D Form

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Jody,
some code snippets

in the OBJECT method (of the object(s) where the drag and drop will be
allowed) on Drag Over event has to return a Zero to accept or -1 to
reject the drag over.
On drop does the actual processing, I have always combined these to
actions into one method, passing the current form method

The pasteboard will contain a path, and a type of drag over object (for
a file or folder "com.4d.private.file.url")
In the code below, if the drag over object is a file or folder return 0
else  fail the drag over event disallowing the drop of the object

The below allows the drag of a selection of files and/or folders, and
populates a listbox with the File/folder name (leaf), the full path
(not presented to the user), a picture to represent a file or folder,
and a text 'kind' not presented to the user.


 In the drop on object method (or in this case the method called by the
Drop on object's object method

case of
: ($Form_Event=On Drag Over)  // NOTE we return a value to calling
object to accept or reject the drag over
$0:=shared_Drag_n_Drop ($Form_Event)

: ($Form_Event=On Drop)  // NOTE no return value needed
shared_Drag_n_Drop ($Form_Event)

:(other event you want to handle)
   //do fancy stuff :)
end case


  //(m) shared_Drag_n_Drop
  //$1 - longint - Form event

  //RETURNS - longint - Accept Drop (0) or fail (-1)
  // ∙ Created 07-10-17 by Chip -
C_LONGINT($1;$Form_Event;$0;$Count)
C_TEXT($Current_Path;$File_Name;$Kind)
C_POINTER($Pic_Pointer)
C_PICTURE($File_pic;$Folder_pic)

$Form_Event:=$1
$0:=-1

Case of
: ($Form_Event=On Drag Over) & (Pasteboard data
size("com.4d.private.file.url")>0)
$0:=0

: ($Form_Event=On Drop)
  //clear listbox

utl_array_Resize_Array
(0;aptr_Column_Vars{l_Pic_Column};aptr_Column_Vars{l_File_Column};aptr_Column_Vars{l_Path_Column};aptr_Column_Vars{l_Kind_Column};->lb_File_List)

If (Pasteboard data size("com.4d.private.file.url")>0)
$Count:=0

Repeat
$Count:=$Count+1
$Current_Path:=Get file from pasteboard($count)

If (Not(utl_is_Empty (->$Current_Path)))
GET PICTURE FROM LIBRARY(2075;$File_pic)
GET PICTURE FROM LIBRARY(2074;$Folder_pic)

  //is the current path a folder, need to get folder name
If ($Current_Path[[Length($Current_Path)]]=Folder separator)
$Pic_Pointer:=->$Folder_pic
$Kind:=Folder
$File_Name:=fileutl_Path_Specified_Folder ($Current_Path)
Else
$Pic_Pointer:=->$File_pic
$Kind:=File
$File_Name:=fileutl_Path_Leaf ($Current_Path)
End if
APPEND TO ARRAY(aptr_Column_Vars{l_Pic_Column}->;$Pic_Pointer->)
APPEND TO ARRAY(aptr_Column_Vars{l_File_Column}->;$File_Name)
APPEND TO ARRAY(aptr_Column_Vars{l_Path_Column}->;$Current_Path)
APPEND TO ARRAY(aptr_Column_Vars{l_Kind_Column}->;$Kind)
End if
Until ($Current_Path="")
x_Example_Change:=""
End if
End case
  //End shared_Drag_n_Drop


On Mon, 4 Jun 2018 09:32:04 -0600, Jody Bevan via 4D_Tech wrote:

> I thought it would be good for an Import to let people drag a file
> from the desktop onto a form. It certainly is not a critical feature,
> the old style select from a file dialog works good for me.
>
> I was looking for an example database, or tech note but could not
> find one. The Drag and Drop Properties is not giving me any
> information with which to accept or decline the on drag over.
>
> I have done lots of drag and drop within the same form before. So I
> am somewhat familiar with the concept, and phases.
>
> Any pointers appreciated.
>
> Jody Bevan
> Developer
>
> Argus Productions Inc. <https://www.facebook.com/ArgusProductions/>
> +1 587-487-6120
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
---------------
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************