summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Search_Chooser.H4
-rw-r--r--src/Fl_Search_Chooser.cxx15
2 files changed, 14 insertions, 5 deletions
diff --git a/src/Fl_Search_Chooser.H b/src/Fl_Search_Chooser.H
index 4e89a1a..aacb57e 100644
--- a/src/Fl_Search_Chooser.H
+++ b/src/Fl_Search_Chooser.H
@@ -24,11 +24,15 @@ class Fl_Search_Browser : public Fl_Select_Browser {
class Fl_Search_Chooser : public Fl_Window {
private:
+ int visible_focus;
+
public:
Fl_Search_Browser *sb;
Fl_Search_Chooser(const char *title);
+ void close();
+
void add(const char *t, void *d);
void *data();
diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx
index 0ef435d..0b3cc93 100644
--- a/src/Fl_Search_Chooser.cxx
+++ b/src/Fl_Search_Chooser.cxx
@@ -56,17 +56,18 @@ static void input_cb(Fl_Input* in, void*c) {
static void ok_cb(Fl_Input* in, void*c) {
Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c;
- sc->hide();
+ sc->close();
}
static void cancel_cb(Fl_Input* in, void*c) {
Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c;
sc->sb->deselect();
- sc->hide();
+ sc->close();
}
Fl_Search_Chooser::Fl_Search_Chooser(const char *title) : Fl_Window(320, 320, title?title:"Choose") {
+ visible_focus = Fl::visible_focus();
Fl::visible_focus(0);
Fl_Group *g = new Fl_Group(10, 10, w() - 10, h() - 10);
sb = new Fl_Search_Browser(g->x(), g->y(), g->w() , g->h() - 100, NULL);
@@ -84,6 +85,12 @@ Fl_Search_Chooser::Fl_Search_Chooser(const char *title) : Fl_Window(320, 320, ti
}
void
+Fl_Search_Chooser::close() {
+ hide();
+ Fl::visible_focus(visible_focus);
+}
+
+void
Fl_Search_Chooser::add(const char *t, void *d) {
sb->add(t, d);
}
@@ -108,10 +115,8 @@ Fl_Search_Chooser::handle(int event) {
if (key == FL_Up || key == FL_Down) {
return sb->handle(event);
} else if (key == FL_Enter) {
- hide();
- return 1;
+ close();
}
-
}
return Fl_Window::handle(event);