On May 14, 2019, at 4:40 PM, Chris Belanger via 4D_Tech <4d_tech@lists.4d.com> 
wrote:

> So my main question is:
> Is it possible to COPY Interface Elements and then PASTE them into 4D’s FORM 
> EDITOR?
> 
> My idea is to:
> 1) have a subform on the FORM DESIGN TOOL that uses FORM DATA (i.e. 
> instant-generated code by the FORM DESIGN TOOL). 
>       I pick the TABLE I am working with, which gives me all the FIELDS in a 
> listBox. [related tables is easy to facilitate too].
> 2) I select the FIELD ITEMS I want to ‘copy’
> 3) Then when I ‘click the button’:
> 4) FORM DESIGN TOOL composites a Form Object complete with all the settings 
> needed (shout out to 4D’s “JSON DEFINITION TOOL” HDI).
>       • the object name is standardized;
>       • the data source is automatically set;
>       • the other aspects of the objects are set according to ’the rules’;
>       • the Label TEXT objects are in place.
>       • the input areas are sized to what is specified in the FORM DESIGN 
> TOOL rather than some random dimension; then I don’t have to fuss a lot with 
> sizing stuff.
>       • even the SCRIPT can be put in place; perhaps with parameters and 
> everything to ‘customize’ it
> 5) The FORM DESIGN TOOL displays these elements in its SUBFORM. Now the 
> elements appear (probably in a column, with LABEL OBJECT style).
> 6) … now I need to be able to ‘COPY’ these in a format that can be PASTED in 
> 4D’s Form Editor.
> 
> The weak link, I think, is that CLIPBOARD stuff. HOW DO I COPY THESE IN A 
> FORMAT THAT CAN BE PASTED IN 4D’S FORM EDITOR ?

If you’re on macOS, there’s a sample Xcode project for a clipboard viewer: 
https://developer.apple.com/library/archive/samplecode/ClipboardViewer/Introduction/Intro.html

It hasn’t been updated in a while, but if you open it with current Xcode, 
simply updating the project to latest recommended settings (a 1-click process) 
will let it compile and run. You could copy form elements, and then examine the 
clipboard types that are specified.  4D’s clipboard commands may not give you 
enough control over clipboard contents and types, but maybe you’ll be lucky and 
v17r5+ puts the json for the form elements in the clipboard instead of the 
binary data that v16 uses?

> Of course, if this is impossible, then I’M stuck!

Not necessarily. You could generate the json for the objects, convert the form 
to json, insert the json for the elements, and reset the form from the json. 
Unless the command to finish the form -> json -> form roundtrip isn’t there 
yet, in which case you could use project mode and just insert the json into the 
file for that particular form.

Caveat:  if you’re generating scripts in objects in one form, and then copying 
those form objects via JSON into another form, where does the object script 
actually reside? Your JSON only has a reference, are scripts global and 
ref-counted? If you’re generating JSON and setting object script references, 
you may need to create global methods to set as references. 

Jim Crate

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to