I agree, Tim, lots of new stuff in 4D and it is quite troublesome to find the 
missing peace of information, especially when documentation and examples are 
spread over 4D doc center, the blog and even on github.

Mostly, the process I’m going through when trying something new is:

- read the docs
- study the examples
- work something out
- get stuck somewhere
- try to find answers in the knowledge base, in the forum or on the NUG
- give up after a few hours and ask the question on the forums or on the NUG ;-)

Much appreciated, thanks!!

Regards,

Rudy Mortier
Two Way Communications bvba 



> On 24 Sep 2018, at 21:37, Tim Nevels via 4D_Tech <[email protected]> wrote:
> 
> On Sep 24, 2018, at 2:00 PM, Rudy Mortier wrote:
> 
>> I can’t figure out how to do this … 
>> 
>> Using a dynamic form, I am trying to build a generic list of records to 
>> display to the user and to allow him to select 1 record.
>> 
>> I used the example from the tech note on how to create a dynamic form that 
>> shows a listbox.
>> 
>> To build this $form object variable, the commands New object and others are 
>> used.
>> 
>> This listbox object is added to the $page object in the $form object, which 
>> will be used in the DIALOG command.
>> 
>> $obj:=New object("type";"listbox";"listboxType";"collection";\ 
>> "dataSource";$colName;"left";0;"top";0;"width";$width+15;"height";$height)
>> 
>> $page:=New object("objects";New object("myListBox";$obj)) $form:=New 
>> object(“pages";New collection(Null;$page))
>> 
>> $form:=New object("windowTitle";"Select a 
>> Map:";"windowMinWidth";500;"windowMinHeight";300;"pages";New 
>> collection(Null;$page))       
>> 
>> Now, this dynamic form only shows a listbox, and I want to add a button to 
>> the form. I assume this button object has to be added to the ‘Objects’ 
>> object in $page.
>> 
>> But, how do I do that? I tried object arrays and collections, but neither of 
>> them produces the correct result. 
> 
> The new Dynamic Forms feature in v17 is new and documentation is very 
> limited, as you already know. Example code is even more limited.  It takes a 
> lot of trial and error to get it to work. I’ve spent hours getting things to 
> work for my little project. And some things I’ve still not been able to 
> figure out. Example: how to set the color of a line or a rectangle. 
> 
> What is desperately needed is the ability to dump a 4D form created in the 
> Form Editor to JSON. Then you would be able to convert an existing form to a 
> dynamic form and you would have example code to understand what is needed to 
> make that button or configure that listbox to work the way you want.  Hoping 
> that command/feature will be released in a v17 R.
> 
> I’ve done some work with Dynamic Forms and here are some tips/info on 
> building them:
> 
> You have to create a starter object for the form. Once that form object is 
> created, you can then add more object to it for each item on the form. Here 
> is sample code that will create that starter object
> 
> $formObject_o:=New object(\
>   "markerHeader";0;\
>   "markerBody";72;\
>   "method";"label_SetObjectFontSize";\
>   "pages";New collection(\
>   Null;\
>   New object(\
>   "objects";New object)))
> 
> You don’t really  need “markerHeader” or “markerBody” for a display form, but 
> I need them because I’m building forms that are used for printing. 
> 
> Next you need to add objects to “pages” collection. Page zero is “Null” in my 
> example, I’ll add objects to Page 1.
> 
> Here is code to add a rectangle to Page 1:
> 
> $object_o:=New object(\
>   "type";"rectangle";\
>   "fill";"transparent";\
>   "strokeWidth";1;\
>   "left";10;\
>   "top";10;\
>   "width";100;\
>   "height";100)
> 
> $objectName_t:=“myRectangle”
> OB SET($formObject_o.pages[1].objects;$objectName_t;$object_o)
> 
> Here is code for an object that is a “input” variable. In this case it is not 
> enterable as I’m using it for printing.
> 
> myVariable_t:=“some value to display”
> 
> $object_o:=New object(\
>   "type";"input";\
>   "dataSource”;”myVariable_t";\
>   "dataSourceTypeHint";"text";\
>   "enterable";False;\
>   "borderStyle";"none";\
>   "fill";"transparent";\
>   "textAlign";"left";\
>   "left”;20;\
>   "top”;20;\
>   "width";200;\
>   "height";11;\
>   "fontFamily";"Arial";\
>   "fontSize";9;\
>   "fontWeight";"Bold”)
> 
> $objectName_t:=“myVariable”
> OB SET($formObject_o.pages[1].objects;$objectName_t;$object_o)
> 
> Finally, here is code to add a button to a form:
> 
> $object_o:=New object(\
>   "type”;"button";\
>   “text”;"OK";\
>   “action”;”Cancel";\
>   "left";100;\
>   "top";100;\
>   "width”;70;\
>   "height”;20)
> 
> $objectName_t:=“myButton”
> OB SET($formObject_o.pages[1].objects;$objectName_t;$object_o)
> 
> As you can see dot notation comes in very handy when working with Dynamic 
> Forms. Each object you add to a page needs a unique name. You decide what  
> that name is.
> 
> Also property names are case sensitive, and even some property values are 
> case sensitive. Using the wrong case will not cause an error, but the object 
> will just not work. So read the docs and if it says that a “type” value is 
> “button” then don’t try “Button” because it may not work. 
> 
> Tim
> 
> *****************************************
> Tim Nevels
> Innovative Solutions
> 785-749-3444
> [email protected]
> *****************************************
> 
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************

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

Reply via email to