Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

UTextfield Class Reference

Text field gadget: single line editor. More...

#include <ugadgets.hpp>

Inheritance diagram for UTextfield:

UTextbox UCombobox List of all members.

Public Member Functions

 UTextfield (const UArgs &=UArgs::none)
 constructor; see also ~UGroup() and the creator shortcut utextfield()
UEditedit ()
const UEditedit () const
virtual void setEditable (bool state=true)
virtual bool isEditable () const

Friends

UTextfieldutextfield (const UArgs &a=UArgs::none)
 creator shortcut that is equivalent to *new UTextField().

Detailed Description

Text field gadget: single line editor.

A UTextfield is a UTextbox that can edit text.

      utextfield( "bla bla" );  
  
is functionally equivalent to:
      utextbox( uedit() + "bla bla" );
  

A textbox can contain arbitrary children (for instance pixmap images, other gadgets...) If a textbox contain several UStr(s) all of them are editable.

      UStr& msg = ustr("my message");
     utextfield( UPix::doc + "Error: " + UPix::ray + msg )
  

Geometry: Same Geometry and Properties as UTextbox except that the text is editable and the default background is white. This gadget keeps its initial size (which is calculated to make children that were added at creation time visible). See UTextbox for details.

Callbacks: as for other UBox subclasses generic callback conditions make it possible to specify callback methods and functions: see class UCond. For instance:

Exemple:

      XXX* obj = ...;
      UStr& msg = ustr("error message");
      utextfield( UPix::ray + msg
                + UOn::action / ucall(obj, &XXX::foo1)
                + UOn::strChange / ucall(obj, &msg, &XXX::foo2)
               )
 
foo1 and foo2 are XXX methods (non member functions can also be specified: see class UCall). There are several ways to retreive the text in callback functions: foo1() retreives all the text included in the textfield while foo2() passes 'msg' as an argument. The text can be changed by foo2() but not by foo1().

  void XXX::foo1(UEvent& e) {
    if (e.getSource()) {          // returns the textfield
      // collates the text enclosed in the textfield and copies it to 's'
      UStr s = e.getSource()->copyText();
      cout << s << endl;
    }

  void XXX::foo2(UStr* s) {
    // 's' points to 'msg'. 'msg' is changed if 's' is changed.
    cout << *s << endl;
  }
 


The documentation for this class was generated from the following files:
Generated on Sat Nov 20 11:58:05 2004 for Ubit[Eric.Lecolinet@enst.fr] by  doxygen 1.3.9.1