home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / fscommand / linux / main.swf / scripts / __Packages / mx / controls / TextInput.as < prev    next >
Text File  |  2007-09-06  |  7KB  |  299 lines

  1. class mx.controls.TextInput extends mx.core.UIComponent
  2. {
  3.    static var symbolName = "TextInput";
  4.    static var symbolOwner = mx.controls.TextInput;
  5.    static var version = "2.0.0.377";
  6.    var className = "TextInput";
  7.    var initializing = true;
  8.    var clipParameters = {text:1,editable:1,password:1,maxChars:1,restrict:1};
  9.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.TextInput.prototype.clipParameters,mx.core.UIComponent.prototype.clipParameters);
  10.    var _maxWidth = mx.core.UIComponent.kStretch;
  11.    var __editable = true;
  12.    var initText = "";
  13.    function TextInput()
  14.    {
  15.       super();
  16.    }
  17.    function addEventListener(event, handler)
  18.    {
  19.       if(event == "enter")
  20.       {
  21.          this.addEnterEvents();
  22.       }
  23.       super.addEventListener(event,handler);
  24.    }
  25.    function enterOnKeyDown()
  26.    {
  27.       if(Key.getAscii() == 13)
  28.       {
  29.          this.owner.dispatchEvent({type:"enter"});
  30.       }
  31.    }
  32.    function addEnterEvents()
  33.    {
  34.       if(this.enterListener == undefined)
  35.       {
  36.          this.enterListener = new Object();
  37.          this.enterListener.owner = this;
  38.          this.enterListener.onKeyDown = this.enterOnKeyDown;
  39.       }
  40.    }
  41.    function init(Void)
  42.    {
  43.       super.init();
  44.       this.label.styleName = this;
  45.       this.tabChildren = true;
  46.       this.tabEnabled = false;
  47.       this.focusTextField = this.label;
  48.       this._color = mx.core.UIObject.textColorList;
  49.       this.label.onSetFocus = function()
  50.       {
  51.          this._parent.onSetFocus();
  52.       };
  53.       this.label.onKillFocus = function(n)
  54.       {
  55.          this._parent.onKillFocus(n);
  56.       };
  57.       this.label.drawFocus = function(b)
  58.       {
  59.          this._parent.drawFocus(b);
  60.       };
  61.       this.label.onChanged = this.onLabelChanged;
  62.    }
  63.    function setFocus()
  64.    {
  65.       Selection.setFocus(this.label);
  66.    }
  67.    function onLabelChanged(Void)
  68.    {
  69.       this._parent.dispatchEvent({type:"change"});
  70.       this._parent.dispatchValueChangedEvent(this.__get__text());
  71.    }
  72.    function createChildren(Void)
  73.    {
  74.       super.createChildren();
  75.       if(this.border_mc == undefined)
  76.       {
  77.          this.createClassObject(_global.styles.rectBorderClass,"border_mc",0,{styleName:this});
  78.       }
  79.       this.border_mc.swapDepths(this.label);
  80.       this.label.autoSize = "none";
  81.    }
  82.    function get html()
  83.    {
  84.       return this.getHtml();
  85.    }
  86.    function set html(value)
  87.    {
  88.       this.setHtml(value);
  89.    }
  90.    function getHtml()
  91.    {
  92.       return this.label.html;
  93.    }
  94.    function setHtml(value)
  95.    {
  96.       if(value != this.label.html)
  97.       {
  98.          this.label.html = value;
  99.       }
  100.    }
  101.    function get text()
  102.    {
  103.       return this.getText();
  104.    }
  105.    function set text(t)
  106.    {
  107.       this.setText(t);
  108.    }
  109.    function getText()
  110.    {
  111.       if(this.initializing)
  112.       {
  113.          return this.initText;
  114.       }
  115.       if(this.label.html == true)
  116.       {
  117.          return this.label.htmlText;
  118.       }
  119.       return this.label.text;
  120.    }
  121.    function setText(t)
  122.    {
  123.       if(this.initializing)
  124.       {
  125.          this.initText = t;
  126.       }
  127.       else
  128.       {
  129.          var _loc2_ = this.label;
  130.          if(_loc2_.html == true)
  131.          {
  132.             _loc2_.htmlText = t;
  133.          }
  134.          else
  135.          {
  136.             _loc2_.text = t;
  137.          }
  138.       }
  139.       this.dispatchValueChangedEvent(t);
  140.    }
  141.    function size(Void)
  142.    {
  143.       this.border_mc.setSize(this.__get__width(),this.__get__height());
  144.       var _loc2_ = this.border_mc.__get__borderMetrics();
  145.       var _loc6_ = _loc2_.left + _loc2_.right;
  146.       var _loc3_ = _loc2_.top + _loc2_.bottom;
  147.       var _loc5_ = _loc2_.left;
  148.       var _loc4_ = _loc2_.top;
  149.       this.tfx = _loc5_;
  150.       this.tfy = _loc4_;
  151.       this.tfw = this.__get__width() - _loc6_;
  152.       this.tfh = this.__get__height() - _loc3_;
  153.       this.label.move(this.tfx,this.tfy);
  154.       this.label.setSize(this.tfw,this.tfh + 1);
  155.    }
  156.    function setEnabled(enable)
  157.    {
  158.       this.enabled = enable;
  159.       this.label.type = !(this.__editable == true || this.enabled == false) ? "dynamic" : "input";
  160.       this.label.selectable = this.enabled;
  161.       var _loc2_ = this.getStyle(!enable ? "disabledColor" : "color");
  162.       if(_loc2_ == undefined)
  163.       {
  164.          _loc2_ = !enable ? 8947848 : 0;
  165.       }
  166.       this.setColor(_loc2_);
  167.    }
  168.    function setColor(col)
  169.    {
  170.       this.label.textColor = col;
  171.    }
  172.    function onKillFocus(newFocus)
  173.    {
  174.       if(this.enterListener != undefined)
  175.       {
  176.          Key.removeListener(this.enterListener);
  177.       }
  178.       if(this.bind != undefined)
  179.       {
  180.          this.updateModel(this.__get__text());
  181.       }
  182.       super.onKillFocus(newFocus);
  183.    }
  184.    function onSetFocus(oldFocus)
  185.    {
  186.       var f = Selection.getFocus();
  187.       var o = eval(f);
  188.       if(o != this.label)
  189.       {
  190.          Selection.setFocus(this.label);
  191.          return undefined;
  192.       }
  193.       if(this.enterListener != undefined)
  194.       {
  195.          Key.addListener(this.enterListener);
  196.       }
  197.       super.onSetFocus(oldFocus);
  198.    }
  199.    function draw(Void)
  200.    {
  201.       var _loc2_ = this.label;
  202.       var _loc4_ = this.getText();
  203.       if(this.initializing)
  204.       {
  205.          this.initializing = false;
  206.          delete this.initText;
  207.       }
  208.       var _loc3_ = this._getTextFormat();
  209.       _loc2_.embedFonts = _loc3_.embedFonts == true;
  210.       if(_loc3_ != undefined)
  211.       {
  212.          _loc2_.setTextFormat(_loc3_);
  213.          _loc2_.setNewTextFormat(_loc3_);
  214.       }
  215.       _loc2_.multiline = false;
  216.       _loc2_.wordWrap = false;
  217.       if(_loc2_.html == true)
  218.       {
  219.          _loc2_.setTextFormat(_loc3_);
  220.          _loc2_.htmlText = _loc4_;
  221.       }
  222.       else
  223.       {
  224.          _loc2_.text = _loc4_;
  225.       }
  226.       _loc2_.type = !(this.__editable == true || this.enabled == false) ? "dynamic" : "input";
  227.       this.size();
  228.    }
  229.    function setEditable(s)
  230.    {
  231.       this.__editable = s;
  232.       this.label.type = !s ? "dynamic" : "input";
  233.    }
  234.    function get maxChars()
  235.    {
  236.       return this.label.maxChars;
  237.    }
  238.    function set maxChars(w)
  239.    {
  240.       this.label.maxChars = w;
  241.    }
  242.    function get length()
  243.    {
  244.       return this.label.length;
  245.    }
  246.    function get restrict()
  247.    {
  248.       return this.label.restrict;
  249.    }
  250.    function set restrict(w)
  251.    {
  252.       this.label.restrict = w != "" ? w : null;
  253.    }
  254.    function get hPosition()
  255.    {
  256.       return this.label.hscroll;
  257.    }
  258.    function set hPosition(w)
  259.    {
  260.       this.label.hscroll = w;
  261.    }
  262.    function get maxHPosition()
  263.    {
  264.       return this.label.maxhscroll;
  265.    }
  266.    function get editable()
  267.    {
  268.       return this.__editable;
  269.    }
  270.    function set editable(w)
  271.    {
  272.       this.setEditable(w);
  273.    }
  274.    function get password()
  275.    {
  276.       return this.label.password;
  277.    }
  278.    function set password(w)
  279.    {
  280.       this.label.password = w;
  281.    }
  282.    function get tabIndex()
  283.    {
  284.       return this.label.tabIndex;
  285.    }
  286.    function set tabIndex(w)
  287.    {
  288.       this.label.tabIndex = w;
  289.    }
  290.    function set _accProps(val)
  291.    {
  292.       this.label._accProps = val;
  293.    }
  294.    function get _accProps()
  295.    {
  296.       return this.label._accProps;
  297.    }
  298. }
  299.