Nana - a C++ framework project  

The Programmer's Guide 
nana::gui::textbox

Description

a nana::gui::textbox is used in a window to permit users to enter and edit text by typing on the keyboard.

Model of

Widget Window 

Public base classes

class widget_object<widget_tag, DrawerTrigger>: public widget


Members

textbox() The default constructor.
textbox(window wd, bool visible) Creates a textbox.
textbox(window wd, const nana::string& title, bool visible = true) Ditto.
textbox(window wd, const nana::char_t* title, bool visible = true) Ditto.
textbox(window wd, const rectangle& r = rectangle(), bool visible = true) Ditto.
textbox& append(const nana::string&, bool at_caret) Appends a string. If at_caret is true, the string is inserted at the position of caret, otherwise, it is appended at end of the textbox.
textbox& border(bool) Shows/Hides the border.
textbox& editable(bool) Set the textbox editable.
bool editable() const Returns true if the textbox is editable.
implement-specified-type& ext_event() const Retrieves the extra event object.
bool getline(size_t n, nana::string& text) const Read the text in a specified line. It returns true for success.
textbox& mask(nana::char_t c) Set a mask character. Text is displayed as mask character if a mask character is set. This is used for hiding some special text, such as password.
textbox& multi_lines(bool) Set the textbox whether it is the mulit-line mode.
bool multi_lines() const Returns true if the textbox is multi-line mode.
bool selected() const Returns true if text is selected.
void select(bool) Selects/Cancels all text.
textbox& tip_string(const nana::string& str) Sets a tip string.
void copy() const Copies the selected text into shared memory, such as clipboard under Windows.
void paste() Pastes the text from shared memory.
void del() Erases the selected text.
void load(const nana::char_t* file); Loads a text file. Attempt to load a uncode encoding text file, be sure the file have a BOM header.
void store(const nana::char_t* file) const; Writes the text to a file with multibytes encoding.
store Refer to the C++03/11 Members

C++03 Member

void store(const nana::char_t* file,nana::unicode::t encoding) const Writes the text to a file with unicode encoding in little-endian.

C++11 Member

void store(const nana::char_t* file, nana::unicode encoding) const Ditto.

File

nana/gui/widgets/textbox.hpp

Notes

1, The return type of ext_event() is coming with textbox, its definition is

struct implement-specifed
{
    nana::fn_group<void()> first_change; //An event for the text first change after text is been opened or stored.
};


An instance of first_change
    Some text editor programs, such as vim, notepad++, when the text is beeing modified, the caption of window will display a special character(such as * ~ +) to indicate changing of text. To implement this feature, you can set a function to the first_change for modifying the caption of your window.

2, The tip string is displayed when textbox is empty and it will be hidden after textbox gets the focus.

See also

None.


Move to The Nana Programmer's Guide Main Page