From 4c58a43ab2bd7ba7195f7aebd3de057cf4c5c698 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 2 Feb 2013 11:51:49 +0000 Subject: [PATCH] simpler widget for strings w/o choices --- Fltk/onelabGroup.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp index 1b372b04b3..f74ac1bd3d 100644 --- a/Fltk/onelabGroup.cpp +++ b/Fltk/onelabGroup.cpp @@ -1115,6 +1115,21 @@ static void onelab_string_button_cb(Fl_Widget *w, void *data) } } +static void onelab_string_input_cb(Fl_Widget *w, void *data) +{ + if(!data) return; + std::string name = FlGui::instance()->onelab->getPath((Fl_Tree_Item*)data); + std::vector<onelab::string> strings; + onelab::server::instance()->get(strings, name); + if(strings.size()){ + Fl_Input *o = (Fl_Input*)w; + onelab::string old = strings[0]; + strings[0].setValue(o->value()); + onelab::server::instance()->set(strings[0]); + autoCheck(old, strings[0]); + } +} + static void onelab_string_input_choice_cb(Fl_Widget *w, void *data) { if(!data) return; @@ -1184,6 +1199,17 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::string &p, Fl_Tree_Item *n, return but; } + // simple string (no menu) + if(p.getChoices().empty() && p.getKind() != "file"){ + Fl_Input *but = new Fl_Input(1, 1, ww, 1); + but->value(p.getValue().c_str()); + but->callback(onelab_string_input_cb, (void*)n); + but->when(FL_WHEN_ENTER_KEY); + but->align(FL_ALIGN_RIGHT); + if(highlight) but->color(c); + return but; + } + // general string input Fl_Input_Choice *but = new Fl_Input_Choice(1, 1, ww, 1); std::vector<Fl_Menu_Item> menu; -- GitLab