Bug? Bug? Or Strange Attractors?

William Lancee

Well-Known Member
Licensed User
Longtime User
As is common in this forum, bugs are often caused by lack of full understanding of the underlying processes. This may be one of those. Nevertheless, I found it interesting and challenging to solve.

In my app, an editText appears to magically change shape, based on a strange attraction to the activity of another editText.

Press "Return" on soft keyboard to advance to next part.
 

Attachments

  • strangeAtractors.zip
    8.8 KB · Views: 170
Last edited:

DonManfred

Expert
Licensed User
Longtime User
My first thought when seeing your code: You should never reuse the same drawable with multiple/different views. Add a third Option to the thread title: "Coding error/mistake".

untested:
B4X:
Sub CreateCD() As ColorDrawable
    Dim cd As ColorDrawable
    cd.Initialize2(Colors.RGB(240, 240 ,255), 3dip, 1dip, Colors.Black)
    Return cd
End Sub
Sub Activity_Create(FirstTime As Boolean)
    Activity.Color = Colors.RGB(245,245,245)


    editBox.Initialize("editBox")
    editBox.TextSize = 20
    editBox.TextColor = Colors.Black
    editBox.Gravity = Gravity.TOP
    editBox.Visible = False
    editBox.Background = CreateCD
    editBox.InputType = Bit.Or(editBox.InputType, 524288)        'to remove autosuggest
    Activity.addView(editBox, 10%x, 33%y, 80%x, 25%y)
 
    inputBox.Initialize("inputBox")
    inputBox.TextSize = 20
    inputBox.TextColor = Colors.Black
    inputBox.Visible = False
    inputBox.Background = CreateCD
    inputBox.InputType = Bit.Or(inputBox.InputType, 524288)        'to remove autosuggest
    Activity.addView(inputBox, 50%x, 10%y, 20%x, 5%y)

    Dim alphnum As String = "abcdefghijklmnopqrstuvwxyz"
    alphnum = alphnum & alphnum.toUppercase & "0123456789,_"
    kbInput.Initialize("kbInput")
    kbInput.SetCustomFilter(inputBox, inputBox.INPUT_TYPE_TEXT, alphnum)
    kbInput.AddHandleActionEvent(inputBox)

    kbEdit.Initialize("kbEdit")
    kbEdit.SetCustomFilter(editBox, editBox.INPUT_TYPE_TEXT, alphnum)
    kbEdit.AddHandleActionEvent(editBox)

    CallSubDelayed(Me, "showProblem")         'callSubDelayed to let the kb handlers get ready
End Sub
 
Last edited:
Top