Interface TinyFdApi
public interface TinyFdApi
API for native file dialogs and message boxes
Backed by TinyFD before Minecraft 26.3 and by SDL from then on
Every method blocks the calling thread until the dialog is closed so call them from a background thread
File dialogs leave the render thread free meanwhile whereas message boxes on Minecraft 26.3 and above
block it until they are closed
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic TinyFdApi@Nullable PathopenFileSelector(@Nullable String title, @Nullable String defaultFilePath, String[] filterPatterns, @Nullable String filterDescription) Open a file selection promptopenFolderSelector(@Nullable String title, @Nullable String defaultFolderPath) Open a folder selection promptPath[]openMultiFileSelector(@Nullable String title, @Nullable String defaultFilePath, String[] filterPatterns, @Nullable String filterDescription) Open a multi file selection promptopenSaveSelector(@Nullable String title, @Nullable String defaultFilePath, String[] filterPatterns, @Nullable String filterDescription) Open a save file selection promptbooleanshowMessageBox(String title, String message, @NotNull String dialog, String icon, boolean defaultValue) Shows a message boxintshowNotification(String title, String message, String icon) Shows a notification
-
Field Details
-
QUESTION_ICON
- See Also:
-
ERROR_ICON
- See Also:
-
WARNING_ICON
- See Also:
-
INFO_ICON
- See Also:
-
OK_DIALOG
- See Also:
-
OK_CANCEL_DIALOG
- See Also:
-
YES_NO_DIALOG
- See Also:
-
YES_NO_CANCEL_DIALOG
- See Also:
-
-
Method Details
-
getInstance
-
openSaveSelector
Path openSaveSelector(@Nullable @Nullable String title, @Nullable @Nullable String defaultFilePath, String[] filterPatterns, @Nullable @Nullable String filterDescription) Open a save file selection promptSame as
openFileSelector(String, String, String[], String)but says save instead of open -
openFileSelector
@Nullable @Nullable Path openFileSelector(@Nullable @Nullable String title, @Nullable @Nullable String defaultFilePath, String[] filterPatterns, @Nullable @Nullable String filterDescription) Open a file selection prompt- Parameters:
title- the title of the promptdefaultFilePath- the path to the default file to selectfilterPatterns- the file extensions to filter by such as new String[]{"*.png", "*.jpg"}filterDescription- the description for said filter such as "Images"- Returns:
- the selected file or null if the user cancelled
-
openMultiFileSelector
Path[] openMultiFileSelector(@Nullable @Nullable String title, @Nullable @Nullable String defaultFilePath, String[] filterPatterns, @Nullable @Nullable String filterDescription) Open a multi file selection promptSame as
openFileSelector(String, String, String[], String)but allows the user to select multiple files -
openFolderSelector
Path openFolderSelector(@Nullable @Nullable String title, @Nullable @Nullable String defaultFolderPath) Open a folder selection promptSame as
openFileSelector(String, String, String[], String)but allows the user to select a folder -
showMessageBox
boolean showMessageBox(String title, String message, @NotNull @NotNull String dialog, String icon, boolean defaultValue) Shows a message box- Parameters:
message- the message which may contain \n and \tdialog- the type of message box to showicon- the icon to usedefaultValue- the default value to return if the user closes the dialog without clicking a button- Returns:
- true if the user clicked the "ok" or "yes" button
false for "cancel" or "no"
-
showNotification
Shows a notification- Parameters:
icon- the icon to use- Returns:
- 0 if the user clicked the "ok" button
1 for "cancel"
-