I would like to use B4XDialog's ShowTemplate to create an InputBox, but I would like to do that using only 1 line of code to call the function.
It would be possible?
Below is as far as I got.
It would be possible?
Below is as far as I got.
B4X:
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
Dim ib As ResumableSub = InputBox("Informe local do servidor", "127.0.0.1", MainForm)
Wait For (ib) complete (resp As String)
Log(resp)
' I'd like just 1 line: resp = inputbox(...)
' Is it possible?
End Sub
Sub InputBox(Mensagem As String, Default As String, f As Form) As ResumableSub
Dim dialog As B4XDialog, Input As B4XInputTemplate, xui As XUI, ret As String
Input.Initialize
Input.lblTitle.Text = Mensagem
dialog.Initialize(f.RootPane)
Input.RegexPattern = ".+" 'require at least one character
Input.Text = Default
Wait For (dialog.ShowTemplate(Input, "OK", "", "CANCELAR")) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then ret = Input.Text Else ret = ""
Return ret
End Sub