[Gambas-user] File Chooser OK event?

Caveat Gambas at ...1950...
Thu Dec 19 12:15:16 CET 2013


And here's the code from the form containing the File Chooser...

Having sent you all this, I realise it perhaps doesn't really answer 
your question (sorry!) but perhaps there's enough in here about raising 
and handling events that it becomes clear how to use the OK and Cancel 
events from the File Chooser itself, should you still wish to do so... :-D

' Done Event is raised only if Done button pressed and a file has been 
chosen and
' returns the chosen file name and the (earlier) provided fileNumber
' See below for details of fileNumber
Event Done(fileName As String, fileNumber As Integer)
' Allows us to keep track of which file we're dealing with if there are 
multiple places
' where you can choose a file on the main Form
' It's returned to the main Form on the Done event
Private fileNumber As Integer

Public Sub pbCancel_Click()

   Me.Close

End

Public Sub pbDone_Click()

   If FileChooser2.SelectedPath = "" Then
     Message.Error("No file chosen!  Cancel to return without selecting 
a file")
     Return
   Endif
   Raise Done(FileChooser2.SelectedPath, fileNumber)
   Me.Close

End

Public Sub setFileNumber(newFileNumber As Integer)

   fileNumber = newfileNumber

End

Public Sub setRoot(newRoot As String)

   FileChooser2.Root = newRoot

End

Public Sub setFilter(newFilter As String)

   FileChooser2.Filter = newFilter

End

Kind regards,
Caveat




More information about the User mailing list