-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support MIME types in file dialog filters on macOS and Linux. #99350
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -138,11 +138,11 @@ | |||||
<param index="6" name="callback" type="Callable" /> | ||||||
<description> | ||||||
Displays OS native dialog for selecting files or directories in the file system. | ||||||
Each filter string in the [param filters] array should be formatted like this: [code]*.txt,*.doc;Text Files[/code]. The description text of the filter is optional and can be omitted. See also [member FileDialog.filters]. | ||||||
Each filter string in the [param filters] array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set. See also [member FileDialog.filters]. | ||||||
Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int[/code]. [b]On Android,[/b] callback argument [code]selected_filter_index[/code] is always zero. | ||||||
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_FILE] feature. Supported platforms include Linux (X11/Wayland), Windows, macOS, and Android. | ||||||
[b]Note:[/b] [param current_directory] might be ignored. | ||||||
[b]Note:[/b] On Android, the filter strings in the [param filters] array should be specified using MIME types, for example:[code]image/png, image/jpeg"[/code]. Additionally, the [param mode] [constant FILE_DIALOG_MODE_OPEN_ANY] is not supported on Android. | ||||||
[b]Note:[/b] Embedded file dialog, and Windows file dialog support only file extensions, Android, Linux and macOS file dialogs also support MIME types. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
[b]Note:[/b] On Android and Linux, [param show_hidden] is ignored. | ||||||
[b]Note:[/b] On Android and macOS, native file dialogs have no title. | ||||||
[b]Note:[/b] On macOS, sandboxed apps will save security-scoped bookmarks to retain access to the opened folders across multiple sessions. Use [method OS.get_granted_permissions] to get a list of saved bookmarks. | ||||||
|
@@ -161,14 +161,15 @@ | |||||
<param index="8" name="callback" type="Callable" /> | ||||||
<description> | ||||||
Displays OS native dialog for selecting files or directories in the file system with additional user selectable options. | ||||||
Each filter string in the [param filters] array should be formatted like this: [code]*.txt,*.doc;Text Files[/code]. The description text of the filter is optional and can be omitted. See also [member FileDialog.filters]. | ||||||
Each filter string in the [param filters] array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set. See also [member FileDialog.filters]. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
[param options] is array of [Dictionary]s with the following keys: | ||||||
- [code]"name"[/code] - option's name [String]. | ||||||
- [code]"values"[/code] - [PackedStringArray] of values. If empty, boolean option (check box) is used. | ||||||
- [code]"default"[/code] - default selected option index ([int]) or default boolean value ([bool]). | ||||||
Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int, selected_option: Dictionary[/code]. | ||||||
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_FILE_EXTRA] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS. | ||||||
[b]Note:[/b] [param current_directory] might be ignored. | ||||||
[b]Note:[/b] Embedded file dialog, and Windows file dialog support only file extensions, Android, Linux and macOS file dialogs also support MIME types. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
[b]Note:[/b] On Linux (X11), [param show_hidden] is ignored. | ||||||
[b]Note:[/b] On macOS, native file dialogs have no title. | ||||||
[b]Note:[/b] On macOS, sandboxed apps will save security-scoped bookmarks to retain access to the opened folders across multiple sessions. Use [method OS.get_granted_permissions] to get a list of saved bookmarks. | ||||||
|
@@ -1895,6 +1896,9 @@ | |||||
<constant name="FEATURE_NATIVE_DIALOG_FILE_EXTRA" value="26" enum="Feature"> | ||||||
The display server supports all features of [constant FEATURE_NATIVE_DIALOG_FILE], with the added functionality of Options and native dialog file access to [code]res://[/code] and [code]user://[/code] paths. See [method file_dialog_show] and [method file_dialog_with_options_show]. [b]Windows, macOS, Linux (X11/Wayland)[/b] | ||||||
</constant> | ||||||
<constant name="FEATURE_NATIVE_DIALOG_FILE_MIME" value="27" enum="Feature"> | ||||||
Native file selection dialog supports MIME types as filters. | ||||||
</constant> | ||||||
<constant name="MOUSE_MODE_VISIBLE" value="0" enum="MouseMode"> | ||||||
Makes the mouse cursor visible if it is hidden. | ||||||
</constant> | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -145,8 +145,8 @@ | |||||
See also [member filters], which should be used to restrict the file types that can be selected instead of [member filename_filter] which is meant to be set by the user. | ||||||
</member> | ||||||
<member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray()"> | ||||||
The available file type filters. Each filter string in the array should be formatted like this: [code]*.txt,*.doc;Text Files[/code]. The description text of the filter is optional and can be omitted. | ||||||
[b]Note:[/b] For android native dialog, MIME types are used like this: [code]image/*, application/pdf[/code]. | ||||||
The available file type filters. Each filter string in the array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set. | ||||||
[b]Note:[/b] Embedded file dialog, and Windows file dialog support only file extensions, Android, Linux and macOS file dialogs also support MIME types. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</member> | ||||||
<member name="mode_overrides_title" type="bool" setter="set_mode_overrides_title" getter="is_mode_overriding_title" default="true"> | ||||||
If [code]true[/code], changing the [member file_mode] property will set the window title accordingly (e.g. setting [member file_mode] to [constant FILE_MODE_OPEN_FILE] will change the window title to "Open a File"). | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.