Author Topic: Using a file dialog with wxSmith?  (Read 1030 times)

Offline Sephiroth

  • Multiple posting newcomer
  • *
  • Posts: 10
Using a file dialog with wxSmith?
« on: November 27, 2023, 12:36:00 am »
I'm new to wxSmith so this is probably me missing something, but I need some guidance. I've got a basic app laid out and working, but now I need to be able to open and save files. In Windows (and X) I had an "OpenFileDialog" I could use. I assume wxWidgets has one of these but I am not sure how to find it. I've got a menu entry setup and functioning for bringing up said dialog, but where is it? How can I get an OFD to open a file so I can read or edit it?

Online Commaster

  • Almost regular
  • **
  • Posts: 171
Re: Using a file dialog with wxSmith?
« Reply #1 on: November 27, 2023, 07:47:11 am »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Using a file dialog with wxSmith?
« Reply #2 on: November 27, 2023, 09:23:20 am »
wxSmith creates an object called FileDialog1, you can change the name. Use something like this in your menu event:
Code
  FileDialog1->SetDirectory(initialDirectory);
  if (FileDialog1->ShowModal() == wxID_OK)
    OpenFile(FileDialog1->GetPath());
EDIT: Fixed object name
« Last Edit: November 27, 2023, 01:17:02 pm by Miguel Gimenez »

Offline Sephiroth

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Using a file dialog with wxSmith?
« Reply #3 on: November 27, 2023, 06:34:04 pm »
I am not seeing "wxFileDialog" on the completion popup in CB, so I am not sure but I do not believe it is working for me. I saw the information linked by Commaster, but again, it does not appear to show up in the auto-complete list so I assumed it wasn't working and I was messing up. Will try regardless this afternoon. Thank you both!

*UPDATE*

I had a typo in the header and it was not including the wx/filedlg.h header. So it WAS me! Thanks for the help, I got it from here.
« Last Edit: November 27, 2023, 06:43:10 pm by Sephiroth »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Using a file dialog with wxSmith?
« Reply #4 on: November 27, 2023, 06:40:21 pm »
You said you are using wxsmith. Did you add a wxFileDialog to your frame/dialog?.

If you want to add one, open wxSmith, go to the Dialogs tab and select wxFilleDialog (the third from the left).