Xfce
Foundation Classes |
|||
« Main Page | Index | |||
Text EntriesThe
Entry widget allows text
to be
typed and
displayed in a single line text box. The text may be set with function
calls that allow new text to replace, prepend or append the current
contents of the Entry widget.
You can create a new Entry widget using one of the following constructors. Entry(); void
set_text(const String& text); The
set_text() method sets the
contents of the Entry widget, replacing the current contents. Note that
the Entry widget implements the Gtk::Editable interface which contains
more methods for
manipulating the contents.
The contents of the entry can be retrieved by calling to the following method: String
get_text() const; If you don't want the contents of the Entry widget to be changed by someone typing into it, you can set its editable state: void
set_editable(bool is_editable);
This method is inherited from
Gtk::Editable
and allows you to toggle the editable state of an entry widget by
passing true or false for the
'is_editable'
argument.
If you are using an Entry widget where you don't want the text entered to be visible, for example when a password is being entered, you can use the following method, which also takes a bool flag: void
set_visibility(bool visible); A
region of the text may be set as
selected
using the following method. This would most often be used after setting
some default text in an Entry, making it easy for the user to remove it.
void
select_region(int start, int end); If
you want to intercept when the
user has
entered
text, you can connect to the 'activate' or 'changed'
signal. An activate signal is emitted when the user hits the enter key
within the Entry widget. A changed signal is emitted when the text
changes, e.g.,
for
every character entered or removed.
Text Entry ExampleThe following example displays a window with an Entry widget and the text 'hello world' highlighted. Checking and unchecking the editable checkbutton will toggle the editable state of the entry widget. Checking and unchecking the visible checkbutton will toggle the visibility state of the text in Entry widget.The header file for XFC Entry is <entry.hh>: #include
<xfc/main.hh> and the source file is <entry.cc>: #include
"entry.hh" Compiling Text Entry
If you compiled and installed XFC yourself, you will find the source
code for Text Entry in the
<examples/entry> source directory along with a Makefile.
If
XFC came pre-installed, or you installed it from an RPM package, you
will
find the source code in the
</usr/share/doc/xfcui-X.X/examples/entry> subdirectory.
In
this case you will have to create the Makefile yourself (replace X.X
with the
version number of the libXFCui library you have installed). |
Copyright © 2004-2005 The XFC Development Team | Top |
XFC
4.4 |