Tool [B4X] Forms Builder - Designer for B4XPreferencesDialog

Discussion in 'Additional libraries, classes and official updates' started by Erel, Apr 9, 2019.

  1. Erel

    Erel Administrator Staff Member Licensed User

    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.
     
    jimmyF likes this.
  2. jimmyF

    jimmyF Active Member Licensed 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
     
    Toky Olivier and walt61 like this.
  3. walt61

    walt61 Active Member Licensed User

    +1 for @jimmyF 's latest suggestion; both Time and Date+Time would be useful, and I'd like to request file- and folder pickers, and the possibility to (optionally) select multiple values from an 'options' list (e.g. in the example, to pock multiple cities from the list)
     
    DroidLyon, jimmyF and Toky Olivier like this.
  4. Erel

    Erel Administrator Staff Member Licensed 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:

    [​IMG]

    This means that the range is 100 - 1000 and the interval is set to 10.
     
  5. Gabino A. de la Gala

    Gabino A. de la Gala Active Member Licensed User

    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?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread in the questions forum and post an example that is not working.
     
  7. Roberto P.

    Roberto P. Well-Known Member Licensed User

    great tool. It would be interesting to have the version to create web pages....
     
  8. MrKim

    MrKim Active Member Licensed 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.
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Currently no.
     
  10. Rusty

    Rusty Well-Known Member Licensed 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: May 20, 2019
  11. jimmyF

    jimmyF Active Member Licensed User

    That we can do. I do it for a number of dialogues that are similar but with different comes.
     
  12. Rusty

    Rusty Well-Known Member Licensed 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 :)
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    Currently no. The validation happens when the user clicks on OK. Note that the list will scroll to the invalid field.
     
  14. Rusty

    Rusty Well-Known Member Licensed 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!
     
  15. jimmyF

    jimmyF Active Member Licensed User

    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
     
  16. Rusty

    Rusty Well-Known Member Licensed User

    Great idea, JimmyF :)
    Thanks, will do!
    Rusty
     
    jimmyF likes this.
  17. AnandGupta

    AnandGupta Active Member Licensed 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
     
  18. Rusty

    Rusty Well-Known Member Licensed User

    In the library, I added some extra information so I could handle the data as it returned to MAIN
    Code:
    '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 ListAs 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:
    Code:
    '                              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...
    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
     

    Attached Files:

    Last edited: May 23, 2019
    AnandGupta likes this.
  19. Rusty

    Rusty Well-Known Member Licensed 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.
     
    jimmyF and AnandGupta like this.
  20. mw71

    mw71 Active Member Licensed User

    Hi

    is it possible to integrate "Button Template"?
    i need it to show a window with the Help.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice