#include <utextbox.hpp>
Inheritance diagram for ubit::UTextfield:
Public Member Functions | |
UTextfield (const UArgs &=UArgs::none) | |
virtual bool | isEditable () const |
virtual UTextfield & | setEditable (bool state=true) |
UEdit & | edit () |
const UEdit & | edit () const |
Static Public Member Functions | |
static UStyle * | createStyle () |
< important: all subclasses MUST contain this declaration. static function that returns the UStyle of this class (see details!). | |
Protected Attributes | |
uptr< UEdit > | pedit |
Friends | |
UTextfield & | utextfield (const UArgs &a=UArgs::none) |
creates a widget for editing a line of text. |
UTextfield has the same default properties and layout as UTextbox except that the UStr(ings) contained in a UTextfield are editable and that its background color is white.
A UTextfield can contain a combination of UStr(ings) and other objects (for instance UIma(ges), ULinkbutton(s), etc.). This makes it possible to create hypertext in a simple way. All strings are then editable.
UStr& s = ustr("World!"); utextfield( UPix::doc + "Hello " + UPix::ray + s )
Callback conditions:
Example:
struct Demo { void enterCB(UStr* s); // instance method static void changeCB(UStr* s); // static function };
Demo* d = new Demo; UStr* s = &ustr("Hello World!"); utextfield(UPix::ray + s + UOn::action / ucall(d, s, &Demo::enterCB) + UOn::strChange / ucall(s, changeCB));
The next example shows another method to retreive the text that is included in a UTextfield (instead of passing 's' as an arg to the callback function):
struct Demo { void keyCB(UEvent&); };
Demo* d = new Demo; utextfield(UPix::ray + "Hello World!" + UOn::ktype / ucall(d, &Demo::keyCB));
void Demo::keyCB(UEvent& e) { if (!e.getSource()) return; UStr s = e.getSource()->retrieveText(); char c = e.getChar(); ... }
Other remarks:
Implementation note:
UStyle * ubit::UTextfield::createStyle | ( | ) | [static] |
< important: all subclasses MUST contain this declaration. static function that returns the UStyle of this class (see details!).
this macro defines the UClass that corresponds to this class and:
Reimplemented from ubit::UTextbox.
Reimplemented in ubit::UCombobox, and ubit::UTextarea.