' Get valx msg class
Sub Class_Globals
Private XUI As XUI
Private Dialog As B4XDialog
Private BView As B4XView
Private title,message As String
Private AllowDecimals, AllowNegative As Boolean
Private lastBUT As Int ' Last button pressed (XUI.DialogResponse_*)
Private lastVAL As Object
' Maybe ?
Private mainActivity As Activity
End Sub
Sub Initialize(maybe As Activity)
mainActivity = maybe '????
BView = mainActivity
Dialog.Initialize (BView)
End Sub
' ask for a value, retur the value or null if cancel is pressed
' based on Input dialogs with XUI Views https://www.b4x.com/android/forum/threads/b4x-input-dialogs-with-xui-views.101197/
' title - message title
' format - message format
' msg - message
' btn1 - button 1 (text XUI.DialogResponse_Positive)
' btn2 - button 2 (text XUI.DialogResponse_Negative)
' btn3 - button 3 (text XUI.DialogResponse_Cancel)
' format - data format
' c - characters (lower and upper case)
' C - characters (upper case)
' n - int numbers (NOT AllowDecimals, AllowNegative)
' N - int numbers (NOT AllowDecimals, NOT AllowNegative)
' d - dec numbers (AllowDecimals, AllowNegative)
' D - dec numbers (AllowDecimals, NOT AllowNegative)
' p/P - phone number
Sub askTEST(defaultValue As Object,tit As String,msg As String,btn1 As String, btn2 As String, btn3 As String, format As String)
Dim input As B4XInputTemplate
title = tit
message = msg
lastVAL = Null
Select format
Case "c" ' TODO c - characters (lower and upper case)
AllowDecimals = False
AllowNegative = False
Case "C" ' TODO C - characters (upper case)
AllowDecimals = False
AllowNegative = False
Case "n" ' n - int numbers (NOT AllowDecimals, AllowNegative)
AllowDecimals = False
AllowNegative = True
Case "N" ' N - int numbers (NOT AllowDecimals, NOT AllowNegative)
AllowDecimals = False
AllowNegative = False
Case "d" ' d - dec numbers (AllowDecimals, AllowNegative)
AllowDecimals = True
AllowNegative = True
Case "D" ' D - dec numbers (AllowDecimals, NOT AllowNegative)
AllowDecimals = True
AllowNegative = False
Case "p","P" ' TODO p/P - phone number
AllowDecimals = False
AllowNegative = False
End Select
Dialog.Title = title
Dialog.PutAtTop = True
input.Initialize
input.lblTitle.Text = message
input.Text = defaultValue
input.ConfigureForNumbers(AllowDecimals, AllowNegative)
Wait For (Dialog.ShowTemplate(input, btn1, btn2, btn3)) Complete (response As Int)
lastBUT = response
If lastBUT = XUI.DialogResponse_Positive Then
lastVAL = input.Text
End If
End Sub
Sub getVAL() As Object
Return lastVAL
End Sub
' TODO WHERE CALL ???? MainForm_Resize (Width As Double, Height As Double)
Sub setSIZE (Width As Double, Height As Double)
If Dialog.Visible Then Dialog.Resize(Width, Height)
End Sub