Tool [B4X] Forms Builder - Designer for B4XPreferencesDialog

Status
Not open for further replies.
SS-2019-04-09_12.32.08.png


FormsBuilder is a desktop tool that helps with building templates for B4XPreferencesDialog: https://www.b4x.com/android/forum/t...alog-cross-platform-forms.103842/#post-651047

The output of FormsBuilder is a json file that is loaded with:
B4X:
prefdialog.LoadFromJson(File.ReadString(File.DirAssets, "Example.json"))

Click on the monitor icon to see the preferences dialog.


Updates

V1.66 - Support for 24 hours mode in time items.
V1.65 - Support for the new Explanation item added to B4XPreferencesDialog v1.65.
V1.50 - Support for two new field types added to B4XPreferencesDialog v1.50: Multiline Text and Decimal Number.
Note that you can set the height of multiline text fields.
V1.10 - Support for light themes. Make sure to also update B4XPreferencesDialog to v1.30.

Make sure to download the latest version of B4XPreferencesDialog: https://www.b4x.com/android/forum/threads/b4x-b4xpreferencesdialog-cross-platform-forms.103842
 

Attachments

  • FormsBuilder-Source.zip
    22.8 KB · Views: 2,869
Last edited:

jimmyF

Active Member
Licensed User
Longtime User
Would it be possible to add a new item type that will accept Time data?
Or, better yet, allow Date and Time entry in the Date type?
-j
 

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
V1.60 released with support for the two new types added in B4XPreferences v1.60: Time and Numeric Range.

The numeric range item expects three values in the extra options:

SS-2019-04-29_12.56.01.png


This means that the range is 100 - 1000 and the interval is set to 10.

I have a problem with default value of Numeric Range Type. It doesn't get the default value loaded into the map.

Could be a bug or is something that I'm doing wrong?
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
great tool. It would be interesting to have the version to create web pages....
 

MrKim

Well-Known Member
Licensed User
Longtime User
Does it have the ability for on View to turn Other Views Visible/Invisible based on their setting? For example I have check boxes which, if checked shows and populates a listview.
 

Rusty

Well-Known Member
Licensed User
Longtime User
Have you added the ability to review/validate each item within the .json list after it is entered and before/when the NEXT/DONE executes? (Don't wait until all fields are entered and the OK button touched.
Including numbers, texts, dates etc...
 
Last edited:

jimmyF

Active Member
Licensed User
Longtime User
can we change the values of the OK, Cancel button texts?
That we can do. I do it for a number of dialogues that are similar but with different comes.
 

Rusty

Well-Known Member
Licensed User
Longtime User
I think this question got lost in my multi-question post above:

Have you added the ability to review/validate each item within the .json list after it is entered and before/when the NEXT/DONE executes? (Don't wait until all fields are entered and the OK button touched.

In other words, can we have an event fire for validation as each view in the form is entered?
Thanks :)
 

Rusty

Well-Known Member
Licensed User
Longtime User
Here's what I did:
I pulled the code from the library and added events for the views.
In the events, I added Callsubs to MAIN that allowed me to validate there.
In the Callsubs I included the B4XPrefItem information so that I could know what was being edited and thus the validation rules.
(I also added new items to the B4XPrefItem Type structure that include Mask, Default values etc.)
I now can validate during and after entry of each view :)
Thanks!
 

jimmyF

Active Member
Licensed User
Longtime User
Here's what I did:
IMHO
Just a suggestion, and from my own experience, you might want to rename the B4XPreferencesDialog to something else, if you make those changes. (Sounds good, incidently! :D )
I think this is a work-in-progress for AnyWhere Software and still in the development stage. It is bound to be overwritten many times in the near future.

-j
 

AnandGupta

Expert
Licensed User
Longtime User
Hi Rusty,

Care to share what you did ? It may help us to understand how to change the lib to suit our requirements.

Regards,

Anand
 

Rusty

Well-Known Member
Licensed User
Longtime User
In the library, I added some extra information so I could handle the data as it returned to MAIN
B4X:
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
'...
'                                            I created a Type structure to hold more than the allowed 2 parameters in the Callsub back to MAIN
 Type TxtItem(Old As String, New As String, Tag As B4XPrefItem)


'                                            I update the B4xPrefItem to contain the new information

Type B4XPrefItem (Title As String, ItemType As Int, Extra As Map, _
      Key As String, Required As Boolean, _
      Default As Object, Mask As String, _
      Link As String, ToolTip As String, Options As List)
'...

'                                            In loadfromJSON, I added parameters to the JSON file
'...
 For Each item As Map In items
  Dim key As String = item.Get("key")
  Dim Link As String = item.Get("link")
  Dim ToolTip As String = item.Get("tooltip")
  Dim title As String = item.Get("title")
  Dim required As Boolean = item.Get("required")
  Dim options As List = item.Get("options")
  If options.IsInitialized = False Then
   options.Initialize
  End If
  Dim itemType As String = item.Get("type")
  Dim default As String = item.Get("default")
  Dim mask As String = item.Get("mask")
      'Title As string, ItemType As Int, Key As String, Default As String, Mask As String, Required As Boolean, Options As List
  Dim pi As B4XPrefItem = CreatePrefItem(title, key, default, mask, required, Link, ToolTip, options)
'                                                I built the prefitems at the top instead of repeatedly within the Select Case for convenience
  Select itemType
   Case "Separator"
    pi.ItemType = TYPE_SEPARATOR
    AddSeparator(pi)
   Case "Boolean"
    pi.ItemType = TYPE_BOOLEAN
    AddBooleanItem(pi)
'...


'                                                  in CreatePrefItem, I added the new items to the B4xPrefItem Type structure

Private Sub CreatePrefItem(Title As String, Key As String, _
      Default As String, Mask As String, Required As Boolean, _
      Link As String, ToolTip As String, _
      Options As List) As B4XPrefItem
    Dim pi As B4XPrefItem
    pi.Initialize
    pi.Link = Link
    pi.ToolTip = ToolTip
    pi.Title = Title
    pi.Key = Key
    pi.Default = Default
    pi.Mask = Mask
    pi.Required = Required
    pi.Options = Options
    Return pi
End Sub

'                                                 add the events that call MAIN validation subs
Private Sub B4XFloatTextField1_EnterPressed
    Dim B4xFld As B4XFloatTextField
    B4xFld = Sender
    Dim edtText As EditText = B4xFld.TextField
    Dim p As B4XView = B4xFld.TextField.Parent.parent
    Dim tg As B4XPrefItem = p.Tag
    If SubExists(Main, "Text_EnterPressed") Then
        CallSub3(Main, "Text_EnterPressed", edtText, tg)
    End If
End Sub
private Sub B4XFloatTextField1_TextChanged (Old As String, New As String)  'text/multiline text
    Dim B4xFld As B4XFloatTextField
    B4xFld = Sender
    Dim p As B4XView = B4xFld.TextField.Parent.parent
    Dim This As TxtItem
    This.Tag = p.Tag
    This.Old = Old
    This.New = New
    Log("TEXT CHANGED " & Old & "   new " & New)  'also password
    If SubExists(Main, "Text_Changing") Then
        CallSub2(Main, "Text_Changing", This)
    End If
End Sub
'                    The below have not been coded yet, they are here as placeholders for now...
Private Sub B4XSwitch1_ValueChanged (Value As Boolean) 'boolean
    If SubExists(Main, "Boolean_Changed") Then
        CallSub2(Main, "Boolean_Changed", Value)
    End If
End Sub
Private Sub PM_ValueChanged (Value As Object)   'Plus Minus/range
    If SubExists(Main, "PM_Changed") Then
        CallSub2(Main, "PM_Changed", Value)
    End If
End Sub
Private Sub pmHours_ValueChanged (Value As Object)
    If SubExists(Main, "PMHours_Changed") Then
        CallSub2(Main, "PMHours_Changed", Value)
    End If
End Sub
Private Sub pmMinutes_ValueChanged (Value As Object)
    If SubExists(Main, "PMMinutes_Changed") Then
        CallSub2(Main, "PMMinutes_Changed", Value)
    End If
End Sub
Private Sub pmAMPM_ValueChanged (Value As Object)
    If SubExists(Main, "PMAMPM_Changed") Then
        CallSub2(Main, "PMAMPM_Changed", Value)
    End If
End Sub
Private Sub B4XComboBox1_SelectedIndexChanged (Index As Int)
    If SubExists(Main, "B4xComboBox_Changed") Then
        Dim Value As String = B4XComboBox1.GetItem(Index)
        CallSub3(Main, "B4xComboBox_Changed", Index, Value)
    End If
End Sub

In MAIN:
B4X:
'                              The below are works in progress, they log the changes...I'll do more with these to verify data against the b4xPrefItems Type
'...
Sub Text_Changing(This As TxtItem)
 If This.New <> This.Old Then
  Log("MAIN text changing " & This.Old & "   new " & This.New & " " & This.Tag.Title)
 End If
End Sub
Sub Text_EnterPressed(New As EditText, tag As B4XPrefItem)
 Log("MAIN Enter Pressed " & New.Text & "   " &  tag.Title)
End Sub
Sub Boolean_Changed(Value As Boolean)
 Log("BOOLEAN CHANGE " & Value)
End Sub
Sub PM_Changed(Value As Object)
 Log("PLUS MINUS CHANGE " & Value)
End Sub
Sub PMHours_Changed(Value As Object)
 Log("PLUS MINUS HOURS CHANGE " & Value)
End Sub
Sub PMMinutes_Changed(Value As Object)
 Log("PLUS MINUS MINUTES CHANGE " & Value)
End Sub
Sub PMAMPM_Changed(Value As Object)
 Log("PLUS MINUS AM/PM CHANGE " & Value)
End Sub
Sub B4xComboBox_Changed(Index As Int, Value As String)
 Log("PLUS MINUS AM/PM CHANGE " & Index & "  value: " & Value)
End Sub
...

'sample JSON...
{
"Version": 1.6,
"Theme": "Light Theme",
"Items": [
{
"link": "CompanyInfo",
"tooltip": "Enter company information here.",
"title": "Company",
"key": "company",
"type": "Text",
"mask": "propercase",
"default": "",
"required": false
},
{
"link": "",
"tooltip": "Please enter your first name.",
"title": "First Name",
"type": "Text",
"mask": "propercase",
"default": "",
"key": "FirstName",
"required": true
},
{
'... more
}
]
}

I've attached the complete clsPreferencesDialog.bas as it stands today. It is actively changing, but the events do fire and the class does work.
Any changes, better ideas, better techniques, bug fixes etc. will be appreciated.
Good luck :)
Rusty
 

Attachments

  • clsPreferencesDialog.bas
    29.6 KB · Views: 405
Last edited:

Rusty

Well-Known Member
Licensed User
Longtime User
BTW,
LINK in the JSON is to load and show another Preference dialog to acquire additional information about the original item.
The ToolTip, is just that an optional text to explain (maybe with a toastmessage) to the user while they are answering it, sort of a help item...
Mask is an editor mask like phone number (nnn) nnn-nnnn, zip code nnnn-nnn, propercase, lowercase,...etc. You can define your own
Default is your own default value, like the local State, City, Zipcode...etc. instead of showing a zero for a numeric or blank for string, etc.
 

mw71

Active Member
Licensed User
Longtime User
Hi

is it possible to integrate "Button Template"?
i need it to show a window with the Help.
 
Status
Not open for further replies.
Top