View on GitHub

FormObject

Parse form JSON 4DForm file, to create classes and generate code, css + macros

Form Object

language language-top code-size release license discord

Parse form JSON 4DForm files, to create classes, provide functions and why not generate some codes.

Macros

Form Event Case of

FormEvent type ahead macro generate Case of for form event code.

FormEventMacro

The macro will search the activated events in the corresponding 4DForm form file, before pasting the code.

Form objects classes instanciation

The base contains type ahead macro FormObjectToPasteBoard(to use in form default method) or Class Code To Pasteboard(FormCode class) form macro to generate some code to instanciate some classes by form objects.

For instance:

This["Button"]:=cs.button.new("Button")
This["Text"]:=cs.text.new("Text")
This["Combo Box"]:=cs.combo.new("Combo Box")
This["Combo Box1"]:=cs.combo.new("Combo Box1")
This["Button Grid"]:=cs.buttonGrid.new("Button Grid")
This["Thermometer1"]:=cs.progress.new("Thermometer1")

Css Macros

AppendFormToCss

Get all or selected object and add object name and class if missing in css main file

AssignClassMacro

Show a popup menu to select an existing class from css and apply to selected objects

MacroSelectClass

Use the code

Getting the current form object as instance of Form object

formParser:=formParser() // do only one time to get the parser

Then in form context

$form:=formParser.current()

Parsing a form ie. getting an instance of Form

by passing the form name

$form:=formParser.parse("MyFormName") // return your form object

by passing the 4DForm file

$formsFolder:=Folder(fk database folder).folder("Project/Sources/Forms")
$formFile:=$formsFolder.folder("FormButton").file("form.4DForm")

$form:=formParser.parse($formFile)

Parsing all forms

$forms:=formParser.parseAll() // collection of Form

Examples of usage

getting an object by its name in specific page

$myButton:=$form.pages[1].objects["Button0"] // instance of formParser.cs.Button (extends formParser.cs.Object)
and manipulate it with functions

There is a log of getter and setters for Object

$myButton.setVisible(False)
$myButton.setEnabled(False)
// or $myButton.apply(New object("visible"; False; "enabled"; False))

get an object without parsing form

Why? to get all function available in Object

$myButton:=formParser.object("MyButtonName")

If you want to specify the type

$myButton:=formParser.object("MyButtonName", "button") // or formParser.button("MyButtonName")

generate event code

Using this code, the form method code will be replaced by a Case of on all available events. This code is used for the macro.

$form.setMethodCode($form.generateEventCode())

example of result

$eventCode:=Form event code
Case of 
  : ($eventCode=On Load)

  : ($eventCode=On Page Change)

  : ($eventCode=On Validate)

  Else 

End case 

Other components

mesopelagique