ubit::UTextfield Class Reference

Textfield widget: single line editor. More...

#include <utextbox.hpp>

Inheritance diagram for ubit::UTextfield:

ubit::UTextbox ubit::UBox ubit::UGroup ubit::UControl ubit::UBrick ubit::UObject ubit::UCombobox ubit::UTextarea List of all members.

Public Member Functions

 UTextfield (const UArgs &=UArgs::none)
virtual bool isEditable () const
virtual UTextfieldsetEditable (bool state=true)
UEditedit ()
const UEditedit () const

Static Public Member Functions

static UStylecreateStyle ()
 < important: all subclasses MUST contain this declaration. static function that returns the UStyle of this class (see details!).

Protected Attributes

uptr< UEditpedit

Friends

UTextfieldutextfield (const UArgs &a=UArgs::none)
 creates a widget for editing a line of text.

Detailed Description

Textfield widget: single line editor.

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:


Member Function Documentation

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.


The documentation for this class was generated from the following files:
Generated on Mon Jan 29 00:20:56 2007 for Ubit by  doxygen 1.4.7