B4X:
Public Sub InputBox2(strPrompt As String, _
strTitle As String, _
strHint As String, _
strDefault As String, _
iTitleFontSize As Int, _
iTitleFontColour As Int, _
iPromptColour As Int, _
iHintColour As Int, _
iInputColour As Int, _
csPrompt As CSBuilder, _
bmpIcon As Bitmap, _
bCancelable As Boolean, _
iPromptHeight As Int, _
bHidePassword As Boolean) As ResumableSub
Dim csPrompt As CSBuilder
Dim csTitle As CSBuilder
Dim oJava As JavaObject
mbHidePassword = bHidePassword
If iTitleFontColour = 0 Then
iTitleFontColour = Colors.RGB(0, 0, 0)
End If
If iPromptColour = 0 Then
iPromptColour = Colors.RGB(0, 0, 0)
End If
If iHintColour = 0 Then
iHintColour = Colors.RGB(0, 0, 0)
End If
If iInputColour = 0 Then
iInputColour = Colors.RGB(0, 0, 0)
End If
If csPrompt.IsInitialized = False Then
csPrompt.Initialize.Size(16).Color(iPromptColour).Append(strPrompt).PopAll
End If
csTitle.Initialize.Typeface(Typeface.DEFAULT).Size(iTitleFontSize).Color(iTitleFontColour).Append(strTitle).PopAll
'note here that the OK and Cancel have been swapped!!
'----------------------------------------------------
oJava = Input_Dialog.ShowAsync(csTitle, "Cancel", "OK", "", bmpIcon, bCancelable)
oJava.RunMethod("setTitle", Array(csTitle))
Wait For (oJava) Dialog_Ready(pnl As Panel) '>>>>>> code stops here!
pnl.LoadLayout("Input_Dialog")
fledtInputbox.Hint = strHint
fledtInputbox.EditText.TextColor = iInputColour
fledtInputbox.EditText.HintColor = iHintColour
'as we have the hint, no prompt label may be needed
If strPrompt.Length > 0 Then
If iPromptHeight = -1 Then
lblInputBox.Height = sUtils.MeasureMultilineTextHeight(lblInputBox, csPrompt) + 20dip
Else
'not sure we need this option, MeasureMultilineTextHeight seems to work well
lblInputBox.Height = iPromptHeight
End If
General.RunLog("InputBox2, lblInputBox.Height: " & lblInputBox.Height)
Input_Dialog.SetSize(96%x, lblInputBox.Height + 200dip)
lblInputBox.Text = csPrompt
Else
Input_Dialog.SetSize(96%x, 200dip)
lblInputBox.Visible = False
End If
If strDefault.Length > 0 Then
fledtInputbox.Text = strDefault
End If
Wait For (oJava) Dialog_Result(res As Int)
'note here that the OK and Cancel have been swapped!!
'----------------------------------------------------
If res = DialogResponse.CANCEL Then
Return fledtInputbox.text 'OK button
Else
Return "" 'Cancel button
End If
End Sub
This code is in a class module and it all runs fine when I run it from main.
However when I run it from a another class the above code just stops at the indicated line.
This is the Sub in that other class:
B4X:
Public Sub Connect2DB(strDatabase As String, strPrompt As String) As ResumableSub
Dim strResult As String
Dim bCreate As Boolean
bCreate = File.Exists(Starter.strAppDir, strDatabase) = False
If strDatabase = "PhonePatsE.db" Then
bEncryptedDB = True
If strPW.Length = 0 Then
Wait For(cEvents.InputBox2(strPrompt, _
"Connect to database", "", "", _
18, 0, 0, 0, 0, Null, General.bmpIcon32, True, -1, bHidePassword)) _
Complete (strResult As String)
Any idea what the problem is here?
I also tried with the above Sub with no return value, but same problem.
RBS