Parse form JSON 4DForm files, to create classes, provide functions and why not generate some codes.
FormEvent
type ahead macro generate Case of
for form event code.
The macro will search the activated events in the corresponding 4DForm
form file, before pasting the code.
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")
Get all or selected object and add object name and class if missing in css main file
Show a popup menu to select an existing class from css and apply to selected objects
formParser:=formParser() // do only one time to get the parser
Then in form context
$form:=formParser.current()
$form:=formParser.parse("MyFormName") // return your form object
$formsFolder:=Folder(fk database folder).folder("Project/Sources/Forms")
$formFile:=$formsFolder.folder("FormButton").file("form.4DForm")
$form:=formParser.parse($formFile)
$forms:=formParser.parseAll() // collection of Form
$myButton:=$form.pages[1].objects["Button0"] // instance of formParser.cs.Button (extends formParser.cs.Object)
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))
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")
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