B4A Library Dialogs library

Status
Not open for further replies.

klaus

Expert
Licensed User
Hi Andrew,

I have some suggestions or wishes for the FileDialog:
Assuming a dialog with two buttons "Open" (positive) and "Cancel"

1) When the user selects another folder and clicks ="Open" without selecting a file, FileDialog.ChosenName=".."

2) When the user shows the FileDialog and clicks onto |Files| and clicks "Open", FileDialog.ChosenName="|Files|"

3) When the user has selected a file and closes the FileDialog, then he shows the FileDialog again but clicks on "Open" without selecting any file, FileDialog.ChosenName=the previously selected file.

In all 3 cases I would prefer that FileDialog.ChosenName="", empty string
With FileDialog.FilePath we can know if the folder has changed.

4) If the user changes the text in the text field and clicks on "Open", it would be interesting that FileDialog.ChosenName=EditText.Text the content of the text field, actually it is the selected file. This would allow to enter a new file name or change an existing (long) one.

5) Couldn't the FileDialog.ChosenFile parameter also be writable ? This would allow to give the user a default filename that he could either confirm or change.

Best regards.
 

agraham

Expert
Licensed User
Sorry! It should, and did!, behave more like you want but an untested last minute change broke it and I didn't notice. :eek: I was using a global variable not a local for temporary values and it spilled over into ChosenName. Version 1.9 fixes it.

I've taken the opportunity to make ChosenName writable.
 

klaus

Expert
Licensed User
Ah! you did say "the return value".
Sorry, in my mind I took FileDialog.Response as the 'return value'.

I will leave it as a "feature" until I need to change something else as it is easily avoided.
No problem :)

Thank's a lot for your valuable work and Best regards.
 

Heinz

Active Member
Licensed User
Dialogs

I have an an Edittext and a Button for searching
in a List in my Activity. Now i want show the items
of the list (list1) in a Dialog with a Listview, if an entry
was found. How can i do it ?
Here is my code, but it don't works.

B4X:
Sub Button2_Click
    Dim such, text As String
    Dim cd As CustomDialog
    Dim Listview2 As ListView
    Listview2.Initialize("Listview2")
    cd.AddView(Listview2, 0, 0, 300, 500)
    cd.Show("Ergebnis ", "", "Abbruch", "", Null)
    such = EditText1.Text
    If such <> "" Then
       Listview2.Clear
       such = such.ToUpperCase
       For i = 0 To List1.Size - 1
            text = List1.Get(i)
            If text.IndexOf(such) > - 1 Then
                Listview2.AddSingleLine(text)
            End If     
       Next
      
    End If
End Sub
 

klaus

Expert
Licensed User
I think that your problem is here:
B4X:
such = such.ToUpperCase
You set such to upper case.
That means that text MUST be upper case also.
If there is at least one lower case character in text, IndexOf2 returns -1
Try to comment out
B4X:
' such = such.ToUpperCase
You must also put
B4X:
  [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  cd.Show([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Ergebnis "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Abbruch"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]
after the For-Next loop.

Best regards.
 
Last edited:

Heinz

Active Member
Licensed User
cd.show(...) after the loop (next)
solved the problem.
thank you.

such = such.ToUpperCase works
proper. the LogCat viewer shows
me the correct results.

many thanks.
 

Cableguy

Expert
Licensed User
I need a feature!!!

Is it possible to, in custom dialog, to add a way to close the view programatically?
I am using a Custom Dialog as an "About" screen, with NO buttons, wich gives it a nicer look, and need a way to close it...I am using a panel to add my labels and such to the Dialog, so I was hopping to use the panel's Click event to close the Dialog!
Please?!
 
Last edited:

agraham

Expert
Licensed User
It is not possible to do this, at least not without a lot of complexity that I'm not going to attempt. I am afraid you will need to close the dialog the way it is intended by one of its buttons or the Back button.

The dialog mechanism in Basic4android is fiendishly complicated because Android doesn't implement modal dialogs so the modality is implemented in Basic4android. While it might appear to you that that the dialog is waiting to be dismissed like a Windows dialog in fact it has actually returned and Basic4android has taken over pumping the message queue so that your code after showing the dialog is blocked until the dialog is closed. Dismissing the dialog is done within this message loop and is tied in with the Activity Pause event so that things are tidied up nicely if a Pause occurs while a dialog is shown.
 

phubocap

New Member
This library contains several modal, that is blocking, dialogs by which the user can enter data. Presently they are an InputDialog for numbers and text, a TimeDialog for times and and a DateDialog for dates.

Note that modal dialogs can close unexpectedly and not return to your code if the Activity needs to close, most likely because the user rotated the device. There is a brief discussion of this in the overall library help in the xml. This can also occur with the Basic4android modal dialogs InputList, InputMultiList, Msgbox and Msgbox2 whose modal mechanism is used by the dialogs in this library.

Edit : - Version 1.1 posted with minor bug fix. See post #6 for details.

Edit : - Version 1.2 posted with Color dialogs. See post #16 for details.

Edit : - Version 1.3 posted with bug fix. See post #19 for details.

Edit : - Version 1.4 posted with a Number dialog. See post #20 for details.

Edit : - Version 1.5 posted with some enhancements. See post #28 for details.

Edit : - Version 1.6 posted with a File Dialog. See post #30 for details.

Edit : - Version 1.7 posted with a minor UI change. See post #33 for details.

Edit : - Version 1.8 posted with a Custom dialog. See post #37 for details.

Edit : - Version 1.9 posted with a bug fix. See post #42 for details.

Edit : - Version 2.0 posted with a bug fix. See post #48 for details.
i like this, but admin isn't allow me download, can anyone help me. Thanks.
 

CharlesR

Member
Licensed User
I am sorry, but I am new to B4A and I would be grateful if you could advise which directories to place all of the unzipped dialog files in.

Thanks in advance.

Charles
 

CharlesR

Member
Licensed User
Thank you. I now have that right now and I can open the dialog in my code, but I can't get the number dialog to return a value to a variable in my code. Could someone post a sample code showing the number dialog being called and returning a value.

Thank you and I am sorry for being a newbie!
 
Status
Not open for further replies.
Top