mikhatri
Member
Hello,
I have some confusion regarding the EditText control in B4A for the focus_changed event.
I am looking for create a public function in my utility class and call it on a B4XPage where i needed. I want to access the EditText focus_changed event via this function to change the border color when the EditText is focused.
Below is a my suggession code for better understanding. Remember, this is not actual code but a conceptual representation of my requirement.
For example, my class name is "Utility" and my function name is "StyleEditText":
Please let me know how to implement it in my project...
Thank you.
I have some confusion regarding the EditText control in B4A for the focus_changed event.
I am looking for create a public function in my utility class and call it on a B4XPage where i needed. I want to access the EditText focus_changed event via this function to change the border color when the EditText is focused.
Below is a my suggession code for better understanding. Remember, this is not actual code but a conceptual representation of my requirement.
For example, my class name is "Utility" and my function name is "StyleEditText":
Code of function:
' Code of Utility Class
Sub Process_Globals
End Sub
' Code of StyleEditText Utility Function
Public Sub StyleEditText(parent As B4XView)
For Each v As B4XView In parent.GetAllViewsRecursive
If TypeOf(v) Is EditText Then
v.AddHandler("EditText_FocusChanged", "EditText_FocusChanged_Event")
End If
Next
End Sub
Sub EditText_FocusChanged_Event(HasFocus As Boolean)
Dim et As EditText = Sender
If HasFocus Then
Log($"${et.Text} gained focus"$)
Dim cd As ColorDrawable
cd.Initialize2(xui.Color_White, DipToCurrent(8), DipToCurrent(2), xui.Color_ARGB(255, 255, 0, 0))
et.Background = cd
Else
Log($"${et.Text} lost focus"$)
Dim cd As ColorDrawable
cd.Initialize2(xui.Color_White, DipToCurrent(8), DipToCurrent(2), xui.Color_Transparent)
et.Background = cd
End If
End Sub
Thank you.