summaryrefslogtreecommitdiff
path: root/plugingui/filebrowser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui/filebrowser.cc')
-rw-r--r--plugingui/filebrowser.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc
index 6eaca8a..3c8b89d 100644
--- a/plugingui/filebrowser.cc
+++ b/plugingui/filebrowser.cc
@@ -68,7 +68,6 @@ static void changeDir(void *ptr)
struct GUI::FileBrowser::private_data *prv =
(struct GUI::FileBrowser::private_data *) ptr;
-
GUI::ListBox *lb = prv->listbox;
GUI::LineEdit *le = prv->lineedit;
std::string value = lb->selectedValue();
@@ -87,6 +86,12 @@ static void changeDir(void *ptr)
}
#endif
+ if(value.empty() && !dir->isDir()) {
+ DEBUG(filebrowser, "Selecting file '%s'\n", dir->path().c_str());
+ if(prv->filesel_handler) prv->filesel_handler(prv->ptr, dir->path().c_str());
+ return;
+ }
+
if(!value.empty() && dir->fileExists(value)) {
std::string file = dir->path() + "/" + value;
DEBUG(filebrowser, "Selecting file '%s'\n", file.c_str());
@@ -137,6 +142,19 @@ static void changeDir(void *ptr)
lb->addItems(items);
}
+static void handleKeyEvent(void *ptr) {
+ struct GUI::FileBrowser::private_data *prv =
+ (struct GUI::FileBrowser::private_data *) ptr;
+
+ GUI::ListBox *lb = prv->listbox;
+ lb->clearSelectedValue();
+ GUI::LineEdit *le = prv->lineedit;
+
+ printf("AAA: %s\n", le->text().c_str());
+ prv->dir->setPath(le->text());
+ changeDir(ptr);
+}
+
GUI::FileBrowser::FileBrowser(GUI::Widget *parent)
: GUI::Widget(parent),
lbl_path(this), lineedit(this), listbox(this), btn_sel(this), btn_esc(this),
@@ -152,8 +170,9 @@ GUI::FileBrowser::FileBrowser(GUI::Widget *parent)
lbl_path.setText("Path:");
- lineedit.setReadOnly(true);
+// lineedit.setReadOnly(true);
prv->lineedit = &lineedit;
+ prv->lineedit->registerEnterPressedHandler(handleKeyEvent, prv);
prv->listbox = &listbox;
listbox.registerSelectHandler(changeDir, prv);