Skip to content
Snippets Groups Projects
Commit 4c58a43a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

simpler widget for strings w/o choices

parent ab94aa11
No related branches found
No related tags found
No related merge requests found
...@@ -1115,6 +1115,21 @@ static void onelab_string_button_cb(Fl_Widget *w, void *data) ...@@ -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) static void onelab_string_input_choice_cb(Fl_Widget *w, void *data)
{ {
if(!data) return; if(!data) return;
...@@ -1184,6 +1199,17 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::string &p, Fl_Tree_Item *n, ...@@ -1184,6 +1199,17 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::string &p, Fl_Tree_Item *n,
return but; 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 // general string input
Fl_Input_Choice *but = new Fl_Input_Choice(1, 1, ww, 1); Fl_Input_Choice *but = new Fl_Input_Choice(1, 1, ww, 1);
std::vector<Fl_Menu_Item> menu; std::vector<Fl_Menu_Item> menu;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment