Changeset 196:9930e7d487d8 for source


Ignore:
Timestamp:
Feb 2, 2011, 8:02:47 PM (13 years ago)
Author:
fnevgeny
Branch:
default
Phase:
public
Message:

Optional conversion factor to/from the text field.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/class/pf/ui/TextField.js

    r146 r196  
    44    extend: qx.ui.form.TextField,
    55   
    6     construct: function(v) {
    7         this.base(arguments, pf.util.Format.numPrint(v));
     6    construct: function(v, f) {
     7        if (typeof f != "undefined" && (f = parseFloat(f)) != 0.0) {
     8            this._f = f;
     9        }
     10
     11        this.base(arguments, pf.util.Format.numPrint(this._f*v));
    812    },
    913   
    1014    members:
    1115    {
     16        _f : 1.0,
     17   
     18        setNumConvFactor: function(f)
     19        {
     20            this._f = parseFloat(f);
     21        },
     22       
    1223        setNumValue: function(v)
    1324        {
    14             this.setValue(pf.util.Format.numPrint(v));
     25            if (typeof v != "undefined") {
     26                this.setValue(pf.util.Format.numPrint(this._f*v));
     27            } else {
     28                this.setValue("");
     29            }
    1530        },
    1631
    1732        getNumValue: function()
    1833        {
    19             return parseFloat(this.getValue());
     34            return parseFloat(this.getValue())/this._f;
    2035        }
    2136    }
Note: See TracChangeset for help on using the changeset viewer.