From ea65a7c0bcd3c8bf5c889b11141210b23b987916 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 16 Jan 2007 15:15:21 +0100 Subject: fix focus issue after choose viewpoint dialog --- src/Fl_Search_Chooser.H | 4 ++++ src/Fl_Search_Chooser.cxx | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src') 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); @@ -83,6 +84,12 @@ Fl_Search_Chooser::Fl_Search_Chooser(const char *title) : Fl_Window(320, 320, ti end(); } +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); -- cgit v1.2.3