diff --git a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h old mode 100644 new mode 100755 index cd96575f96..8ba2960bf2 --- a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h +++ b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h @@ -256,7 +256,8 @@ private: class WizardComp : public Component, private ButtonListener, private ComboBoxListener, - private TextEditorListener + private TextEditorListener, + private FileBrowserListener { public: WizardComp() @@ -264,7 +265,9 @@ public: projectName (TRANS("Project name")), nameLabel (String::empty, TRANS("Project Name") + ":"), typeLabel (String::empty, TRANS("Project Type") + ":"), - fileBrowser (FileBrowserComponent::saveMode | FileBrowserComponent::canSelectDirectories, + fileBrowser (FileBrowserComponent::saveMode + | FileBrowserComponent::canSelectDirectories + | FileBrowserComponent::doNotClearFileNameOnRootChange, NewProjectWizardClasses::getLastWizardFolder(), nullptr, nullptr), fileOutline (String::empty, TRANS("Project Folder") + ":"), targetsOutline (String::empty, TRANS("Target Platforms") + ":"), @@ -303,6 +306,8 @@ public: addChildAndSetID (&fileBrowser, "fileBrowser"); fileBrowser.setBounds ("fileOutline.left + 10, fileOutline.top + 20, fileOutline.right - 10, fileOutline.bottom - 32"); fileBrowser.setFilenameBoxLabel ("Folder:"); + fileBrowser.setFileName (File::createLegalFileName (projectName.getText())); + fileBrowser.addListener (this); addChildAndSetID (&createButton, "createButton"); createButton.setBounds ("right - 130, bottom - 34, parent.width - 30, parent.height - 30"); @@ -409,6 +414,16 @@ public: fileBrowser.setFileName (File::createLegalFileName (projectName.getText())); } + void selectionChanged() override {} + + void fileClicked (const File&, const MouseEvent&) override {} + void fileDoubleClicked (const File&) override {} + + void browserRootChanged (const File&) override + { + fileBrowser.setFileName (File::createLegalFileName (projectName.getText())); + } + ComboBox projectType; PlatformTargetsComp platformTargets; diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp old mode 100644 new mode 100755 index 8f41549072..2dc3364fb1 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -387,7 +387,7 @@ void FileBrowserComponent::fileDoubleClicked (const File& f) { setRoot (f); - if ((flags & canSelectDirectories) != 0) + if ((flags & canSelectDirectories) != 0 && (flags & doNotClearFileNameOnRootChange) == 0) filenameBox.setText (String::empty); } else @@ -432,7 +432,9 @@ void FileBrowserComponent::textEditorReturnKeyPressed (TextEditor&) { setRoot (f); chosenFiles.clear(); - filenameBox.setText (String::empty); + + if ((flags & doNotClearFileNameOnRootChange) == 0) + filenameBox.setText (String()); } else { diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h old mode 100644 new mode 100755 index a1151ef02f..62d28742da --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h @@ -51,18 +51,19 @@ public: */ enum FileChooserFlags { - openMode = 1, /**< specifies that the component should allow the user to - choose an existing file with the intention of opening it. */ - saveMode = 2, /**< specifies that the component should allow the user to specify - the name of a file that will be used to save something. */ - canSelectFiles = 4, /**< specifies that the user can select files (can be used in - conjunction with canSelectDirectories). */ - canSelectDirectories = 8, /**< specifies that the user can select directories (can be used in - conjuction with canSelectFiles). */ - canSelectMultipleItems = 16, /**< specifies that the user can select multiple items. */ - useTreeView = 32, /**< specifies that a tree-view should be shown instead of a file list. */ - filenameBoxIsReadOnly = 64, /**< specifies that the user can't type directly into the filename box. */ - warnAboutOverwriting = 128 /**< specifies that the dialog should warn about overwriting existing files (if possible). */ + openMode = 1, /**< specifies that the component should allow the user to + choose an existing file with the intention of opening it. */ + saveMode = 2, /**< specifies that the component should allow the user to specify + the name of a file that will be used to save something. */ + canSelectFiles = 4, /**< specifies that the user can select files (can be used in + conjunction with canSelectDirectories). */ + canSelectDirectories = 8, /**< specifies that the user can select directories (can be used in + conjuction with canSelectFiles). */ + canSelectMultipleItems = 16, /**< specifies that the user can select multiple items. */ + useTreeView = 32, /**< specifies that a tree-view should be shown instead of a file list. */ + filenameBoxIsReadOnly = 64, /**< specifies that the user can't type directly into the filename box. */ + warnAboutOverwriting = 128, /**< specifies that the dialog should warn about overwriting existing files (if possible). */ + doNotClearFileNameOnRootChange = 256 /**< specifies that the file name should not be cleared upon root change. */ }; //==============================================================================