C4 Engine
C4 Engine API Documentation

class FilePicker

Defined in:  C4FilePicker.h
A FilePicker class encapsulates a file picker box.
Definition

class FilePicker : public Window, public LinkTarget<FilePicker>, public Completable<FilePicker>

Member Functions
FilePicker::GetFileNameCount Returns the number of files that are currently selected.
FilePicker::GetFileName Returns the name of the file that is currently selected.
Constructor

FilePicker(const char *title, const char *directory, uint32 flags = 0, const char *panel = nullptr);

Parameters
title The file picker's displayed title.
directory The path to the directory that is initially displayed by the file picker.
flags Flags that affect the appearance and behavior of the file picker. See below for a list of possible values.
panel The name of the panel resource to use for the picker dialog. To use the default file picker, this should be set to nullptr.
Description
The FilePicker class provides a standard interface for selecting files. When the user selects a file, the file picker's completion callback is called. The completion callback can then retrieve the path to the selected file by calling the FilePicker::GetFileName function.

Options that control the appearance and behavior of the file picker can be controlled by specifying a combination (through logical OR) of the following constants in the flags parameter.
kFilePickerSave Display an editable text field where the file name can be typed in.
kFilePickerMultipleSelection Allow multiple files to be selected in the file list simultaneously. This should not be set if the kFilePickerSave flag is set.
kFilePickerEnableRootDirectory Causes the root directory name to be included in the file name. If the kFilePickerSave flag is set, then this flag also allows a file to be specified in the root directory.
kFilePickerStayInsideRootDirectory Don't allow navigation outside (above) the root directory.
The directory parameter specifies the directory for which a list of files is initially displayed. If the kFilePickerNoDirectories flag is not specified, then the user can navigate to any directory beneath the initial directory. If the kFilePickerSubdirectory flag is specified, the user can also navigate upward one level from the initial directory (and subsequently to any directory beneath that level).

If the kFilePickerSave flag is specified, then an editable text box is displayed in which the user can enter a file name. This is useful for allowing new files to be created.

If the file picker is cancelled, then the completion callback is not called.
Base Classes
Window The FilePicker class is a specific type of window.
LinkTarget<FilePicker> File pickers support smart linking with the Link class.
Completable<FilePicker> The completion callback is called when the file picker is dismissed.