textbox - qPCR4vir/nana-docs GitHub Wiki
Doxygen description of textbox
// Construct textbox to be displayed on panel
nana::textbox txt( panel );
// Locate in panel
txt.move( { topleftX, topleftY, width, height } );
// show starting text
std::string textvalue = "Type here";
txt.caption( textvalue );
// Using the lost focus event so as to do an update only when user is actually done editing
txt->events().mouse_leave([this]
{
if( txt.caption() != textvalue ) {
textvalue = txt.caption();
status.caption("You entered "+textvalue);
}
});
Interface for textbox to define a group of highlighted words:
Define a scheme:
void set_highlight(const std::string& name, const color& fgcolor, const color& bgcolor);
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<nana::string> kw_list);
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<std::string> kw_list_utf8);
It's easy-to-use.
using namespace nana;
//textbox tb;
tb.set_highlight ( "sqlrev" , colors::dark_blue, colors::yellow);
tb.set_keywords ( "sqlrev" , false, true, { "select", "from", "where"});
tb.set_highlight ( "table-name", colors::red, {});
tb.set_keywords ( "table-name", false, true, { "studentbase" });
tb.set_highlight ( "field", colors::deep_sky_blue, {});
tb.set_keywords ( "field", false, true, { "score" });
Another example:
_textBox.set_highlight("place_keywords", nana::colors::blue, nana::colors::white);
_textBox.set_keywords ("place_keywords", true,true, { "arrange", "collapse", "gap", "grid",
"margin", "min", "max", "repeated", "variable", "vertical", "vert", "weight", "horizontal" });
_textBox.set_highlight("place_simbols", nana::colors::blue, nana::colors::yellow);
_textBox.set_keywords ("place_simbols", true,false, {"<",">", "|", "%", "[","]" });