Hi all,
I have a legacy B4A app built using the File -> Default type.
The Activity is a Login form.
The layout has:
One image
2 EditTexts (username, password)
1 button (btnLogin)
2 Labels - (lblCopyright, lblVersion) The 2 Labels are positioned at the very bottom of the layout, with the Vertical Anchor set to the bottom.
The 2 Labels are correctly positioned above the keyboard when the keyboard is shown. This happens in the Sub Activity_Resume
The 2 Labels are positioned to the original bottom correctly, when the keyboard is hidden. This happens when the "down" keyboard button is pressed.
For both situations the IME_HeightChanged is called and that's how the 2 Labels are positioned correctly. See the code.
When the btnLogin button is pressed, it first validates the login credentials. Then if the credentials are valid, it then a IME.HideKeyboard is called to hide the keyboard. This works as expected, but the IME_HeightChanged is never called to adjust the 2 Labels position, as expected.
As mentioned, the Labels do not return to their original position, because the IME_HeightChanged is never called with the IME.HideKeyboard.
Am I expecting the wrong functionality? Am I missing something? If so what must be done to set the 2 Labels to the bottom position as expected?
Regards,
Mark Stuart
I have a legacy B4A app built using the File -> Default type.
The Activity is a Login form.
The layout has:
One image
2 EditTexts (username, password)
1 button (btnLogin)
2 Labels - (lblCopyright, lblVersion) The 2 Labels are positioned at the very bottom of the layout, with the Vertical Anchor set to the bottom.
B4X:
Sub Activity_Create(FirstTime As Boolean)
IME.Initialize("IME")
Activity.LoadLayout("Login")
End Sub
Sub Activity_Resume
Utils.Load_Logo(ImageView1)
lblCopyright.Text = Utils.SetAppCopyright
lblVersion.Text = $"Version ${Utils.SetAppVersion}"$
txtPassword.InputType = 144
IME.AddHeightChangedEvent
IME_HeightChanged(100%y,0)
ClearLoginData
txtUserName.RequestFocus
CallSubDelayed(Me, "ShowKeyboard")
End Sub
The 2 Labels are correctly positioned above the keyboard when the keyboard is shown. This happens in the Sub Activity_Resume
The 2 Labels are positioned to the original bottom correctly, when the keyboard is hidden. This happens when the "down" keyboard button is pressed.
For both situations the IME_HeightChanged is called and that's how the 2 Labels are positioned correctly. See the code.
When the btnLogin button is pressed, it first validates the login credentials. Then if the credentials are valid, it then a IME.HideKeyboard is called to hide the keyboard. This works as expected, but the IME_HeightChanged is never called to adjust the 2 Labels position, as expected.
B4X:
Sub btnLogin_Click
'force Username to lower case
txtUserName.Text = txtUserName.Text.ToLowerCase
Dim sPassword As String = ""
Dim sScanAdmin As Int = 0
'validate input entry
If txtUserName.Text.Length = 0 Then
ToastMessageShow("Username required!",False)
txtUserName.RequestFocus
Return
Else If txtPassword.Text.Length = 0 Then
ToastMessageShow("Password required!",False)
txtPassword.RequestFocus
Return
End If
DBCalls.GetAppServerInfo
'Log("server: " & Constants.AppServer)
'passed input validation
Starter.gUserID = txtUserName.Text.ToLowerCase
If Starter.gUserID <> "" Then
Dim UserInfo() As String
UserInfo = DBCalls.GetUserInfo(Starter.gUserID)
If UserInfo <> Null Then
sPassword = UserInfo(0)
sScanAdmin = UserInfo(1)
'validate password
If sPassword = txtPassword.Text Then
'hide soft keyboard
IME.HideKeyboard
'check ScanAdmin for loading of which layout: InvScan or Setup
Starter.gScanAdmin = sScanAdmin
'is scanner user
If sScanAdmin = 0 Then
DBCalls.SaveLastLogin(Starter.gUserID)
'New behavior... 7/14/2025 MS
'Load Zones List, allowing the user to select
'the zone they want from the list.
'When the Zone is selected, the app
'takes the user to the Scan Activity.
StartActivity(SelectZone)
'is admin user
Else If sScanAdmin = 1 Then
DBCalls.SaveLastLogin(Starter.gUserID)
StartActivity(Administration)
'userid not found
Else If sScanAdmin = Null Then
ToastMessageShow("User access denied.",False)
End If
Else
ToastMessageShow("Incorrect credentials!",False)
txtPassword.RequestFocus
End If
Else
ToastMessageShow("Incorrect credentials!",False)
txtUserName.RequestFocus
End If
End If
End Sub
B4X:
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
If NewHeight < OldHeight Then 'keyboard appears
lblCopyright.Top = NewHeight - lblCopyright.Height
lblVersion.Top = NewHeight - lblVersion.Height
Else 'keyboard hides
lblCopyright.Top = 100%y - lblCopyright.Height
lblVersion.Top = 100%y - lblVersion.Height
End If
End Sub
As mentioned, the Labels do not return to their original position, because the IME_HeightChanged is never called with the IME.HideKeyboard.
Am I expecting the wrong functionality? Am I missing something? If so what must be done to set the 2 Labels to the bottom position as expected?
Regards,
Mark Stuart