B4A Library SD: Dialogs

Discussion in 'Additional libraries, classes and official updates' started by Star-Dust, Jun 11, 2017.

  1. Star-Dust

    Star-Dust Expert Licensed User

    (No WRAP, No Java Only B4A)

    I finally finished my first Library. I suppose it's full of bugs. I rely on your messages and your benevolence (Do not be too bad with me)

    There are already many Dialogs libraries already, but since B4A 7.01 is available, the question arises. How do people who have an old version without WaitFor and Sleep will have to keep obsolete libraries because the new ones will no longer be supported.

    So I decided to create an updated library that would use both DoEvents (the so hated) but it would work without it. Here is my library.

    With the attached examples you can see how to use the bookstore in the ways (with and without DoEvents). Probably you can also use it in a third way with WaitFor, but I have not tried it.

    SD_Dialogs
    Author:
    Star-Dust
    Version: 0.07
    • ColorDIalog
      Events:
      • Response (Response as int As , RGBcolor as int As )
      Fields:
      • response As Int
      • rgbcolor As Int
      Methods:
      • argb (alpha As Int, Red As Int, Green As Int, Blue As Int) As Int
      • class_globals As String
      • doeventwaitresponse As Int
      • initialize (Me_CallBack As Object, EventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • show (Title As String, Positive As String, Cancel As String, Negative As String) As String
    • DateDialog
      Events:
      • Response (Response as int As , DateTick as long As )
      Fields:
      • datetick As Long
      • response As Int
      Methods:
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • class_globals As String
      • datatotext (Tick As Long) As String
      • doeventwaitresponce As Int
      • getdayofmounth As Int
        only get
      • getmounth As Int
        only get
      • getyear As Int
        only get
      • initialize (MeCallBack As Object, EventName As String, Date As Long) As String
        Initializes the object. You can add parameters to this method if needed.
      • setdate (DayOfMounth As Int, Mounth As Int, Year As Int) As String
      • show (Title As String, Positive As String, Cancel As String, Negative As String) As String
    • Dialogs
      Fields:
      • cancel As Int
      • input_type_decimal_number As Int
      • input_type_email As Int
      • input_type_first_upcase As Int
      • input_type_multi_line As Int
      • input_type_no_suggest As Int
      • input_type_none As Int
      • input_type_numbers As Int
      • input_type_password As Int
      • input_type_phone As Int
      • input_type_suggest As Int
      • input_type_text As Int
      • input_type_upcase As Int
      • negative As Int
      • positive As Int
      • response_not_initialized As Int
      • response_not_selected As Int
      Methods:
      • process_globals As String
    • FileDialog
      Events:
      • Response (Response as int As , FileName as string As )
      Fields:
      • filename As String
      • path As String
      • response As Int
      • showonlyfolders As Boolean
      Methods:
      • addfilter (Filter As String, Description As String) As String
      • class_globals As String
      • clearfilter As String
      • doeventwaitresponse As Int
      • initialize (MyActivity As ActivityWrapper, Me_CallBack As Object, EventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • show (Title As String, Positive As String, Cancel As String, Negative As String) As String
      • timerdialog (MillSec As Int) As String
      Permissions:
      • android.permission.WRITE_EXTERNAL_STORAGE
    • InputDialog
      Events:
      • Response (Response as int As , InputText as string As )
      Fields:
      • colorestyle As Int
      • hint As String
      • input As String
      • input_type_decimal_number As Int
      • input_type_email As Int
      • input_type_first_upcase As Int
      • input_type_multi_line As Int
      • input_type_no_suggest As Int
      • input_type_none As Int
      • input_type_numbers As Int
      • input_type_password As Int
      • input_type_phone As Int
      • input_type_suggest As Int
      • input_type_text As Int
      • input_type_upcase As Int
      • inputtype As Int
      • response As Int
      • showkeyboard As Boolean
      • style_ellipse As Int
      • style_fringe As Int
      • style_trapeze As Int
      Methods:
      • class_globals As String
      • doeventwaitresponse As Int
      • initialize (MyActivity As ActivityWrapper, Me_CallBack As Object, EventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • show (Message As String, Title As String, Positive As String, Cancel As String, Negative As String) As String
        -100 Error not initialized
      • styledshow (Message As String, Title As String, Positive As String, Cancel As String, Negative As String, GraficStyle As Int) As String
        -100 Error not initialized
        Stlye 0 = Trapezio
        Style 1 = Ellisse
        Style 2 = Frangia
      • timerdialog (MillSec As Int) As String
    • ListDialog
      Events:
      • Response (Response as int As , ListResponse as List As )
      Fields:
      • colorestyle As Int
      • listresponse As List
      • response As Int
      Methods:
      • class_globals As String
      • doeventwaitresponse As Int
      • initialize (Me_CallBack As Object, EventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • show (ListItem As List, Title As String, MultiSelect As Boolean, Positive As String, Cancel As String, Negative As String) As String
        -100 Error not initialized
      • timerdialog (MillSec As Int) As String
    • MessageBox
      Events:
      • Response (Response as int As )
      Fields:
      • colorestyle As Int
      • response As Int
      • style_ellipse As Int
      • style_fringe As Int
      • style_trapeze As Int
      Methods:
      • class_globals As String
      • doeventwaitresponse As Int
      • initialize (MyActivity As ActivityWrapper, Me_CallBack As Object, EventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • newmsgbox (Message As String, Title As String, Positive As String, Cancel As String, Negative As String) As String
        -100 Error not initialized
      • styledmsgbox (Message As String, Title As String, Positive As String, Cancel As String, Negative As String, GraficStyle As Int) As String
        -100 Error not initialized
        Stlye 0 = Trapezio
        Style 1 = Ellisse
        Style 2 = Frangia
      • timerdialog (MillSec As Int) As String
    • SignatureDialog
      Events:
      • Response (Response as int As , Signature as bitmap As )
      Fields:
      • colorestyle As Int
      • response As Int
      • sign As BitmapWrapper
      Methods:
      • class_globals As String
      • doeventwaitresponse As Int
      • initialize (Me_CallBack As Object, EventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • show (Title As String, Positive As String, Negative As String) As String
        -100 Error not initialized
      • timerdialog (MillSec As Int) As String
    • TimeDialogs
      Events:
      • Response (Response as int As , TimeTick as long As )
      Fields:
      • response As Int
      • timetick As Long
      Methods:
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • class_globals As String
      • doeventwaitresponce As Int
      • initialize (MeCallBack As Object, EventName As String, Time As Long) As String
        Initializes the object. You can add parameters to this method if needed.
      • show (Title As String) As String
    ____________________________________________________________________________
    rel. 0.0.2
    New:
    NameEvent on Initialize: You can raise an Event other than Class_Response (See spoiler)
    Initializing so Class.Initialize(Activity, Me, "NameEvent"), when it raise the event, launches the sub NameEvent_Response (Arg ...).

    If a StringEvent that contains underscores (for example, Class.Initialize(Activity, Me, "Event_Click") call the sub with the exact name entered as a topic, In this case, Event_Click, without passing arguments.

    rel. 0.0.3
    New:
    Field: Intercept_KEYCODE_BACK As Boolean

    rel. 0.0.5
    New: Modify Initialize
    , not required pass Activity

    rel. 0.0.6
    New:
    Fix Bug FileDialog, Add button "create folder"

    rel. 0.0.7
    New:
    Fix Bug DateDialog, B4A 8.8+ and SDK28+

    New XUI version of the multi-platform library is available. You can download it from here
     

    Attached Files:

    Last edited: Jun 1, 2019
  2. Star-Dust

    Star-Dust Expert Licensed User

    DoEventWaitResponse is present on all classes and is modal.
    Alternatively, you can use the NameEvent_Response event to capture the response event (not modal).
    This event can also be used with WaitFor (I believe)



     
    Last edited: Jun 11, 2017
    Mashiane, Phayao, jparraga and 3 others like this.
  3. Star-Dust

    Star-Dust Expert Licensed User

    Last edited: Jun 13, 2017
    moster67 and Johan Schoeman like this.
  4. Star-Dust

    Star-Dust Expert Licensed User

    release 0.03

    i Add Intercept_KEYCODE_BACK propriety
    If set to True, when you press on KeyBack, closes the dialogs. If set to False, it raises the Activity_KeyPressed event

    Code:
    Dim B As MessageBox
       
    'B.Initialize(Activity,Me,"MsgBox") old version
    B.Initialize(Me,"MsgBox")
    B.Intercept_KEYCODE_BACK=
    True
    B.NewMsgBox(
    "What do you want?","Ask","Si","cancel","No")
     
    Last edited: Jul 8, 2017
  5. Star-Dust

    Star-Dust Expert Licensed User

    Example:
    Modal
    Code:
    Sub ButtonMsgBox_Click
        
    Dim B As MessageBox
        
    Dim R As Int

        B.Initialize(Me,
    "")
        B.NewMsgBox(
    "What do you want?","Ask","Si","cancel","No")
        R=B.DoEventWaitResponse

        ToastResponse(R,
    "")
    End Sub
    With Event
    Code:
    Sub ButtonMsgBox_Click
        
    Dim B As MessageBox

        B.Initialize(Me,
    "MsgBox")
        B.NewMsgBox(
    "What do you want?","Ask","Si","cancel","No")

    End Sub

    Sub MsgBox_ClickResponse(Response As Int)
        ToastResponse(Response,
    "")
    End Sub
    With Timer
    Code:
    Sub ButtonMsgBox_Click
        
    Dim B As MessageBox

        B.Initialize(Me,
    "MsgBox")
        B.NewMsgBox(
    "What do you want?","Ask","Si","cancel","No")
        B.TimerDIalog(
    5000' If you want Timer for 5 sec
        'Modal
        R=B.DoEventWaitResponse  if you like old dear DoEvents,
    End Sub

    Sub ButtonMsgBox2_Click
        
    Dim B As MessageBox

        B.Initialize(Me,
    "MsgBox")
        B.NewMsgBox(
    "What do you want?","Ask","Si","cancel","No")
        B.TimerDIalog(
    5000' If you want Timer for 5 sec
        ' With Event
    End Sub

    Sub MsgBox_ClickResponse(Response As Int)
        ToastResponse(Response,
    "")
    End Sub
    But if I wanted to avoid DoEvents, I do not have WaitFor and I do not even want to put the code in another sub raised by the event but all together as in WaitFor, what should I do?

    With WaitFor
    Code:
    Dim D As MessageBox

    D.Initialize(
    Activity,Me,"MsgBox")

    D.NewMsgBox(
    "Test","Try","Yes","Cancel","No")

    Dim sf As Object = D
    Wait For (sf) MsgBox_Response(Response As Int)
    Log(D.Response)
    If D.Response=DialogResponse.POSITIVE Then ToastMessageShow("Ok",False)
    No WaitFor, No DoEvent, No SUB RaiseEvent
    Code:
    Sub ButtonMsgBox_Click

        
    Dim MsgB As MessageBox

        
    If Not(Sender Is MessageBox) Then
            
    ' First
            MsgB.Initialize(Activity,Me,"ButtonMsgBox_Click")
            MsgB.NewMsgBox(
    "What do you want?","Ask","Si","cancel","No")
        
    Else
            
    ' After Click
            MsgB = Sender
            ToastResponse(MsgB.Response,
    "No Wait For")
        
    End If
    End Sub
     
    Last edited: Jul 11, 2017
  6. netsistemas

    netsistemas Member Licensed User

    good job, but in DateDlg DoEvents the app crack.

    Congratulations for your library.
     
  7. Star-Dust

    Star-Dust Expert Licensed User

    Thanks for the tip. Would you like to see the code you used? So I can see why it generates errors
    Crash report would also be useful

    Esample use DateDialog with DoEvents:
    Code:
    Dim D As DateDialog
    Dim R As Int

    D.Initialize(Me,
    "",DateTime.Now)
    D.Show(
    "Select my date","Si","Cancella","No")

    R=D.DoEventWaitResponce

    ToastResponse(R,D.DataToText(D.DateTick))
     
    Last edited: Jul 8, 2017
  8. PABLO2013

    PABLO2013 Active Member Licensed User

  9. Star-Dust

    Star-Dust Expert Licensed User

    Update: 0.05. Download on Post#1
     
  10. Peter Simpson

    Peter Simpson Expert Licensed User

    Excellent library @Star-Dust. Hmm wait a minute, wasn't the Stardust a Mob ran casino in Las Vagas :p
    Oops sorry, I went off route there for a few seconds. But anyway I do like this library boss ;)
     
    Last edited: Jul 11, 2017
    Star-Dust and DonManfred like this.
  11. GIS

    GIS Active Member Licensed User

    ciao, la sub ToastResponse non viene attivata. Cosa Sbaglio? grazie


    Code:
    Sub ListView1_ItemClick (Position As Int, Value As Object)

     
        
    Dim StringMom As String = List1.Get(Position)
     
        
    Dim stringArray() As String = Regex.Split("\|",StringMom)
     
        
    Dim MsgB As MessageBox
        
        
    If Not(Sender Is MessageBox) Then
            
    ' First
            MsgB.Initialize(Me,"ListView1_ItemClick")
            MsgB.NewMsgBox(stringArray(
    1),stringArray(0),"Si","cancel","No")
            
    'R=MsgB.DoEventWaitResponse
        Else
            
    ' After Click
            MsgB = Sender
            ToastResponse(MsgB.Response,
    "No Wait For")
        
    End If
     
    End Sub




    Sub ToastResponse(R As Int, Message As String)
        
    Select R
            
    Case DialogResponse.POSITIVE
                
    ToastMessageShow("Positive " & CRLF & Message,False)
            
    Case DialogResponse.NEGATIVE
                
    ToastMessageShow("Negative " & CRLF & Message,False)
            
    Case DialogResponse.CANCEL
                
    ToastMessageShow("Cancel " & CRLF & Message,False)
        
    End Select

    End Sub
     
  12. Star-Dust

    Star-Dust Expert Licensed User

    Stai usando un metodo particolare, creato per evitare il WaitFor.
    ListView1_ItemClick riceve dei parametri (Position As Int, Value As Object), ma MsgB.Initialize(Me,"ListView1_ItemClick") richiama un instanza di una Sub senza parametri, come un Button_Click. Quindi non può funzionare

    prova così, dotrebbe funzionare:
    Code:
    Sub ListView1_ItemClick (Position As Int, Value As Object)
        Event_Click
    End Sub

    Sub Event_Click
        
    Dim StringMom As String = List1.Get(Position)
        
    Dim stringArray() As String = Regex.Split("\|",StringMom)
        
    Dim MsgB As MessageBox
       
        
    If Not(Sender Is MessageBox) Then
            
    ' First
            MsgB.Initialize(Me,"Event_Click")
            MsgB.NewMsgBox(stringArray(
    1),stringArray(0),"Si","cancel","No")
            
    'R=MsgB.DoEventWaitResponse
        Else
            
    ' After Click
            MsgB = Sender
            ToastResponse(MsgB.Response,
    "No Wait For")
        
    End If
    End Sub


    Sub ToastResponse(R As Int, Message As String)
        
    Select R
            
    Case DialogResponse.POSITIVE
                
    ToastMessageShow("Positive " & CRLF & Message,False)
            
    Case DialogResponse.NEGATIVE
                
    ToastMessageShow("Negative " & CRLF & Message,False)
            
    Case DialogResponse.CANCEL
                
    ToastMessageShow("Cancel " & CRLF & Message,False)
        
    End Select

    End Sub
     
    Last edited: Mar 12, 2019
  13. GIS

    GIS Active Member Licensed User

    ok grazie alla tua modifica ho solo dovuto aggiungere aggiungere una variabile per poter passare la position della ListView....
     
    Star-Dust likes this.
  14. GIS

    GIS Active Member Licensed User

    ciao, come faccio a controllare se uno preme senza inserire niente?
    Code:
    Sub ButtonInputDialog_Click
        
    Dim I As InputDialog
        
    Dim R As Int
     
        I.Initialize(Me,
    "")
        I.Input=
    ""
        I.Show(
    "Digita il codice di verifica","Verifica E-Mail","OK","Cancel","")
        r=I.DoEventWaitResponse
     
     
        NumVerificaIn = I.Input
     
        ToastResponse(R,I.Input)
     
     
    End Sub


    Sub ToastResponse(R As Int, Message As String)
        
    Select R
            
    Case DialogResponse.POSITIVE
                Conferma_Click
            
    Case DialogResponse.NEGATIVE
                
    ToastMessageShow("Cancel ",False)
            
    Case DialogResponse.CANCEL
             
        
    End Select


    End Sub


    'Utente ha ricevuto email ed immesso codice registrazione
    Sub Conferma_Click
        
    'check se il codice immesso è uguale a quello inviato; se OK salva dati su server e lancia Main
        If (numVerifica <> NumVerificaIn)  Or (NumVerificaIn = ""Then
            
    Msgbox("Verifica E-mail Errata!!!""ERRORE!!")
            
    Activity.Finish
        
    Else
    l'app si chiude dandomi questo errore:
    java.lang.NumberFormatException: Invalid double: "". Verificando NumVerificaIn ineffetti mi da nullo. NumVerificaIn l'ho dichiarata come stringa.
     
    Last edited: Apr 10, 2019
  15. Star-Dust

    Star-Dust Expert Licensed User

    Please write in this part of the forum in English.

    I'll try tonight, and I'll let you know
     
  16. Star-Dust

    Star-Dust Expert Licensed User

    It is always necessary to put the event name when initializing.

    Furthermore with the new versions of B4A the modal version with DoEvent does not seem to work properly anymore.
    So I suggest you do as follows

    Code:
    Sub ButtonInputDialog_Click
        
    Dim I As InputDialog
        
        I.Initialize(Me,
    "MsgBox")
        I.Input=
    ""
        I.Show(
    "Digita il codice di verifica","Verifica E-Mail","OK","Cancel","")
        
        
    Dim sf As Object = I
        
    Wait For (sf) MsgBox_Response(Response As Int)
        
        
    If Response=DialogResponse.POSITIVE Then
            NumVerificaIn = I.Input
            
    ToastMessageShow(NumVerificaIn,True)
        
    Else if Response=DialogResponse.CANCEL Then
            
    ToastMessageShow("Cancel ",False)
        
    else if Response=DialogResponse.NEGATIVE Then
            
    ToastMessageShow("Negative",False)
        
    End If
     
     
    End Sub
     
  17. GIS

    GIS Active Member Licensed User

    hello, thanks but the problem remains. If I press ok without entering anything I always wrote error before. However it is not a big problem. If they press ok without entering anything, it returns to me initial screen and I'm fine. At this point it's a problem for users who don't do the right things. For the moment I keep it that way over time we will see.
     
  18. GIS

    GIS Active Member Licensed User

    ok solved it was my mistake. I practically made the comparison with a long variable and a string. If I entered a number everything was fine if instead I didn't insert anything, obviously it made me error. Sorry if I made you lose time ......
     
  19. abilio486software

    abilio486software Member Licensed User

    Hi,

    Great library!!

    Date picker:

    - I think you have a problem in the library when you select 31 of May and after press top left button to change to April, you get an error because the library can't process "31/April".

    - How to set the "Yes" answer to the center or to the right of the dialog?


    Regards,
    Abilio
     
  20. abilio486software

    abilio486software Member Licensed User

     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice