I'd like to implement a simple wxFileDialog in wxCrafter where the user can go to File | New and be greeted with a dialog where they can choose to open a file. It would be nice to see Common Dialogs in wxCrafter if they aren't already there. How do others handle this type of event?
I could create a dialog and put a wxFilePickerCtrl in it, but I was hoping there was a faster way.
wxFileDialog in wxCrafter
-
- CodeLite Curious
- Posts: 7
- Joined: Sat Sep 14, 2013 1:50 am
- Genuine User: Yes
- IDE Question: C++
- Contact:
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: wxFileDialog in wxCrafter
I never had to design such a dialog before since wxWidgets provide you with a simpler way:musictreeAstro wrote:I'd like to implement a simple wxFileDialog in wxCrafter where the user can go to File | New and be greeted with a dialog where they can choose to open a file. It would be nice to see Common Dialogs in wxCrafter if they aren't already there. How do others handle this type of event?
I could create a dialog and put a wxFilePickerCtrl in it, but I was hoping there was a faster way.
In your frame class, at the OnFileNew handler, add this code:
Code: Select all
#include <wx/filedlg.h>
...
void MyFrame::OnFileNew( wxCommandEvent& event )
{
wxUnusedVar(event);
wxString new_path = ::wxFileSelector(_("Select a file:"));
if ( new_path.IsEmpty() ) {
// do something with the file
}
}
http://docs.wxwidgets.org/2.9.5/group__ ... 86b01928bf
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Curious
- Posts: 7
- Joined: Sat Sep 14, 2013 1:50 am
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: wxFileDialog in wxCrafter
Thanks! That's exactly what I was looking for. I'm new to wxWidgets (and designing GUIs) and hadn't come across wxFileSelector yet.
Forrest
Forrest