bool FileBrowserComponent::currentFileIsValid() const
{
    if (isSaveMode())
        return ! getSelectedFile (0).isDirectory();
    else
        return getSelectedFile (0).exists();
}
void FileBrowserComponent::textEditorReturnKeyPressed (TextEditor&)
{
    if (filenameBox.getText().containsChar (File::separator))
    {
        const File f (currentRoot.getChildFile (filenameBox.getText()));

        if (f.isDirectory())
        {
            setRoot (f);
            chosenFiles.clear();
            filenameBox.setText (String::empty);
        }
        else
        {
            setRoot (f.getParentDirectory());
            chosenFiles.clear();
            chosenFiles.add (f);
            filenameBox.setText (f.getFileName());
        }
    }
    else
    {
        fileDoubleClicked (getSelectedFile (0));
    }
}
예제 #3
0
 /**
     Returns a vector with all selected file paths.
     @return a vector with all selected file paths.
  */
 std::vector<FilePath> getSelectedFilePaths() const {
     std::vector<FilePath> result;
     int count = getSelectedFileCount();
     for(int index = 0; index < count; ++index) {
         result.push_back(FilePath(getSelectedFile(index)));
     }
     return result;
 }
bool FileBrowserComponent::currentFileIsValid() const
{
    const File f (getSelectedFile (0));

    if (isSaveMode())
        return (flags & canSelectDirectories) != 0 || ! f.isDirectory();

    return f.exists();
}
//==============================================================================
void FileBrowserComponent::sendListenerChangeMessage()
{
    Component::BailOutChecker checker (this);

    if (previewComp != nullptr)
        previewComp->selectedFileChanged (getSelectedFile (0));

    // You shouldn't delete the browser when the file gets changed!
    jassert (! checker.shouldBailOut());

    listeners.callChecked (checker, &FileBrowserListener::selectionChanged);
}
예제 #6
0
void OpenRecent::browseForFileOnce()
{
	if (exitEarly) {
		return;
	}
	if (0 == recentFiles.size()) {
		exitEarly = true;
		setResult(Rejected);
		browseForFile();
		if (! getSelectedFile().isEmpty()) {
			setResult(Accepted);
		}
	}
}
예제 #7
0
	void mouseDrag (const MouseEvent& /*e*/)
	{
		if (fileDragEnabled)
		{
			StringArray files;
            
            for (int i = 0; i < getNumSelectedFiles(); i++) 
            {
                File file (getSelectedFile (i));
                
                if (file.existsAsFile()) 
                    files.add (file.getFullPathName());
            }
            
            fileDragEnabled = false;
            performExternalDragDropOfFiles (files, false);
		}
	}