diff --git a/ui/CHANGES.md b/ui/CHANGES.md index 74670d941..f9bc1ed77 100644 --- a/ui/CHANGES.md +++ b/ui/CHANGES.md @@ -6,7 +6,8 @@ - **Changed**: `FileTypeFilter` select box won't be shown when `FileChooser` `SelectionMode` is set to `DIRECTORIES` - **Changed**: `FileChooser` now can be closed by pressing enter when file name field has focus - **Changed**: `Dialogs#showOKDialog` can be closed using enter and escape key -- **Changed**: `FileChooser` will fallback to default directory when `setDirectory` is called with invalid file handle (either non existing path or poiting to file) +- **Changed**: [#176 (comment)](https://github.com/kotcrab/vis-editor/issues/176#issuecomment-237046516) - `FileChooser` path text field will now show end of the path when it's too long +- **Changed**: `FileChooser` will fallback to default directory when `setDirectory` is called with invalid file handle (either non existing path or pointing to file) - Fixes possible crash when current directory is removed while it's open in file chooser - Removed protected `handleAsyncError`, no longer needed diff --git a/ui/src/main/java/com/kotcrab/vis/ui/widget/file/FileChooser.java b/ui/src/main/java/com/kotcrab/vis/ui/widget/file/FileChooser.java index 241e957dc..d349a35a2 100644 --- a/ui/src/main/java/com/kotcrab/vis/ui/widget/file/FileChooser.java +++ b/ui/src/main/java/com/kotcrab/vis/ui/widget/file/FileChooser.java @@ -153,7 +153,6 @@ public class FileChooser extends VisWindow implements FileHistoryCallback { private DirsSuggestionPopup dirsSuggestionPopup; private VisLabel fileTypeLabel; private PopupMenu viewModePopupMenu; - private FileHandle defaultStartingDirectory; /** @param mode whether this chooser will be used to open or save files */ public FileChooser (Mode mode) { @@ -289,9 +288,7 @@ private void createToolbar () { @Override public void activeItemChanged (MenuItem newItem, boolean changedByKeyboard) { if (changedByKeyboard == false || newItem == null) return; - - currentPath.setText(newItem.getText().toString()); - currentPath.setCursorPosition(currentPath.getText().length()); + setCurrentPathFieldText(newItem.getText().toString()); } }); @@ -317,7 +314,7 @@ public boolean keyDown (InputEvent event, int keycode) { addRecentDirectory(file); } else { showDialog(POPUP_DIRECTORY_DOES_NOT_EXIST.get()); - currentPath.setText(currentDirectory.path()); + setCurrentPathFieldText(currentDirectory.path()); } event.stop(); } @@ -330,7 +327,7 @@ public boolean keyDown (InputEvent event, int keycode) { @Override public void keyboardFocusChanged (FocusEvent event, Actor actor, boolean focused) { if (focused == false) { - currentPath.setText(currentDirectory.path()); + setCurrentPathFieldText(currentDirectory.path()); } } }); @@ -499,6 +496,11 @@ else if (actor instanceof Layout) } } + private void setCurrentPathFieldText (String text) { + currentPath.setText(text); + currentPath.setCursorAtTextEnd(); + } + private void createFileTextBox () { VisTable table = new VisTable(true); VisLabel nameLabel = new VisLabel(FILE_NAME.get()); @@ -862,7 +864,7 @@ private void rebuildFileList () { } deselectAll(); - currentPath.setText(currentDirectory.path()); + setCurrentPathFieldText(currentDirectory.path()); if (showBusyBarTask.isScheduled() == false) { Timer.schedule(showBusyBarTask, 0.2f); //quite period before busy bar is shown @@ -1054,7 +1056,7 @@ private void updateSelectedFileFieldText () { selectedFileTextField.setText(builder.toString()); } - selectedFileTextField.setCurosrAtTextEnd(); + selectedFileTextField.setCursorAtTextEnd(); } private void removeInvalidSelections () {