Bug? [SOLVED] B4XPreferencesDialog Bug - when data-map predefined and change at runtime value to nothing/null - returns old value !

Magma

Expert
Licensed User
Longtime User
Hi there..

Well I think that found a little bug.. but annoying..
moving [question] from:
https://www.b4x.com/android/forum/t...nge-a-value-to-null-if-something-else.137748/

Hope we can fix, or better fixing the lib..

The problem is when predefine the data-map using at b4xpreferencesdialog and change at runtime (enduser using the form-dialog) a value to null + then press ok / data map will returned the old predefined value :-(

So if you wanna edit an old record from a db with form-dialog and give somewhere null/"" value if needed.. will not change :(

Thanks for your time...

ps: May be I am wrong or something making it be wrong... who knows ?

AT THE NEXT POST (#2) - THE SOLUTION
 
Last edited:

Magma

Expert
Licensed User
Longtime User
Found Solution - Hope help others... too - was quite simple

...Well I have edit the source of the latest (1.75) b4xlib B4xPreferencesDialog... at these points:
B4X:
...
Private Sub CommitChanges (Data As Map) As Boolean
....
            Case TYPE_TEXT, TYPE_PASSWORD, TYPE_MULTILINETEXT  
                Dim ft As B4XFloatTextField = ItemPanel.GetView(0).Tag
                If ft.Text <> "" Then  'added by me
                    Value = ft.Text 'This was before
                else 'added by me
                    Value = "" 'added by me
                end if 'added by me
...
    If mEventName <> "" And xui.SubExists(mCallback, mEventName  & "_IsValid", 1) Then
        Dim Valid As Boolean = CallSub2(mCallback, mEventName & "_IsValid", Temp)
        If Valid = False Then Return False
    End If
    Data.clear 'added by me
    For Each key As String In Temp.Keys
        Data.Put(key, Temp.Get(key))
        'log(Temp.Get(key)) 'fixed by me
    Next

Now works...

Attaching library... caution fix - for version 1.75
 

Attachments

  • B4XPreferencesDialog.b4xlib
    44.9 KB · Views: 187
Last edited:

AnandGupta

Expert
Licensed User
Longtime User
Thanks for solution, but try to re-name the b4xlib and also the class inside, so that members can use both official and your library as required.
 

Magma

Expert
Licensed User
Longtime User
Both why ? - it is not a total different thing... I think that may be Erel need to fix it at next version... ofcourse if he want.. and if it is the right way..

and ofcourse it is a simple fix - everyone can do it...
 

AnandGupta

Expert
Licensed User
Longtime User
Both why ? - it is not a total different thing... I think that may be Erel need to fix it at next version... ofcourse if he want.. and if it is the right way..

and ofcourse it is a simple fix - everyone can do it...
Yes, but one may forget when updating the lib with new version, and may face logical error in old project.
It is just an advise which is given here for all lib changes, may be of Erel or other members release.
 
Top