TGFileDialog process

Hi,

How can I process the case in the TGFileDialog session if the user selected some files but after that he/she pressed the Cancel button. So how can I check whether the Cancel was pressed and connect it to some function?

Thank you,
Balint

Hi Balint,

The last parameter in TGFileDialog constructor gives this information; for example:TGFileInfo fi; new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi); if (!fi.fFilename) // Cancel was clicked, selection was ignored (fi.fFilename is 0) else // OK was selected, fi.fFilename contains some info
Best regards, Ilka

Hi Ilka,

I am still experiencing some strange behaviour when selecting multiple files.
If I have TGFileInfo fi, then fi.fFilename is really set to zero after selecting the Cancel button but if I make a multiple selection (just selecting the files) and then press then Cancel button fi.fFileNamesList is not an empty something. Thereby I cannot distinguish the cases in the situation when there was a multiple selection made by the User, and then: 1) the Cancel button was pressed, or 2) the Open/Save button was selected.
I am using ROOT 5.14.
I took a look at the source code $ROOTSYS/gui/src/TGFileDialog.cxx and in the line 421 I see the following:

case kIDF_CANCEL:
fFileInfo->fFilename=0;
DeleteWindow();
break;

Isn’t it possible to first check whether fFileNamesList has something and if yes then delete it too?

But maybe I misunderstood the behaviour. In this case, please help!

Thank you,
Balint

Hi Balint,

Your observation is correct and corresponds to the current code (fFileInfo->fFilename is set to 0 in both cases: Cancel clicked; multiple file selection switched ON). And yes, the fFileInfo->fFileNamesList should be set to 0 if Cancel was clicked in case of multiple selection. I will fix that.

Thank you for pointing this case.

Cheers, Ilka

Hi Balint,

The fix is uploaded in CVS. Do you need it for the next patch release of version 5.14?

Thank you, Ilka

Hi Ilka,

I am working under Mac OS X, and the easiest way to set up ROOT was to download the binaries, but I think in this case it doesn’t help so I will want to just download the latest version 5.16 and try to compile it.

Thank you!

Balint

Hi Balint,

Please take sources from CVS head. If you download sources of version 5.16, I can send you the diff file (send me a message to Ilka.Antcheva@cern.ch in case you need it).

Cheers, Ilka