Skip to content

Commit

Permalink
Merge pull request #56626 from KoBeWi/FilterDialog
Browse files Browse the repository at this point in the history
 Improve FileDialog filters
  • Loading branch information
akien-mga authored Jan 8, 2022
2 parents d332412 + b403954 commit 5a61822
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/classes/FileDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<return type="void" />
<argument index="0" name="filter" type="String" />
<description>
Adds [code]filter[/code] as a custom filter; [code]filter[/code] should be of the form [code]"filename.extension ; Description"[/code]. For example, [code]"*.png ; PNG Images"[/code].
Adds [code]filter[/code] to the list of filters, which restricts what files can be picked.
A [code]filter[/code] should be of the form [code]"filename.extension ; Description"[/code], where filename and extension can be [code]*[/code] to match any string. Filters starting with [code].[/code] (i.e. empty filenames) are not allowed.
Example filters: [code]"*.png ; PNG Images"[/code], [code]"project.godot ; Godot Project"[/code].
</description>
</method>
<method name="clear_filters">
Expand Down
1 change: 1 addition & 0 deletions scene/gui/file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ void FileDialog::clear_filters() {
}

void FileDialog::add_filter(const String &p_filter) {
ERR_FAIL_COND_MSG(p_filter.begins_with("."), "Filter must be \"filename.extension\", can't start with dot.");
filters.push_back(p_filter);
update_filters();
invalidate();
Expand Down

0 comments on commit 5a61822

Please sign in to comment.