baseedittext.lzx
<library>
<include href="base/baseformitem.lzx"/>
<class name="_newinternalinputtext" extends="inputtext">
<attribute name="ignorecallup" value="false
"/>
<method name="construct" args="parent, args">
// args from parent
if ( parent['password'] != null ) args.password = parent.password;
parent._field = this;
super.construct( parent, args );
</method>
<handler name="onfocus" args="s">
if (parent['onfocus']) parent.onfocus.sendEvent(s);
</handler>
<handler name="onblur" args="s">
if (parent['onblur']) parent.onblur.sendEvent(s);
</handler>
<handler name="onkeyup" args="kc">
if (parent['onkeyup']) parent.onkeyup.sendEvent(kc);
</handler>
<handler name="onkeydown" args="kc">
if (parent['onkeydown']) parent.onkeydown.sendEvent(kc);
</handler>
<handler name="ontext" method="doOnText"/>
<method name="doOnText" args="ignore">
if (! this.ignorecallup) {
parent.doSetValue(this.text,false,true);
}
this.ignorecallup = false;
</method>
<method name="getFocusRect">
var fx = parent.getAttributeRelative('x',canvas);
var fy = parent.getAttributeRelative('y',canvas);
var fw = parent.getAttributeRelative('width',canvas);
var fh = parent.getAttributeRelative('height',canvas);
return [fx,fy,fw,fh];
</method>
<method name="getPrevSelection">
if ( parent['getPrevSelection'] ) return parent.getPrevSelection()
return null; // default tab order occurs
</method>
<method name="getNextSelection">
if ( parent['getNextSelection'] ) return parent.getNextSelection()
return null; // default tab order occurs
</method>
</class>
<class name="baseedittext" extends="baseformitem" focusable="false">
<attribute name="text" type="html" setter="this.doSetValue(text, false, false)"/>
<attribute name="value" value="null
" setter="this.doSetValue(value, false, false)"/>
<attribute name="multiline" value="false
"/>
<attribute name="password" value="false
"/>
<attribute name="maxlength" value="null
" type="number"/>
<attribute name="pattern" value="$once{null}" type="string"/>
<attribute name="height" value="20
"/>
<attribute name="width" value="106
"/>
<attribute name="fontsize" value="13
"/>
<event name="onvalue"/>
<attribute name="fgcolor" setter=""/>
<attribute name="_fgcolor" value="0
"/>
<attribute name="_initialtext" value="
" type="string"/>
<attribute name="_initialtexty" value="false
"/>
<attribute name="_field" value="null
"/>
<setter name="height" args="h">
super.setAttribute('height', h);
this._initialtexty = (!this._initcomplete);
if (this._initcomplete) this._placeTextY()
</setter>
<setter name="multiline" args="newMultiline">
this.multiline = newMultiline;
if (this._initcomplete) {
this._field.setAttribute('multiline', newMultiline);
this._placeTextY();
}
</setter>
<method name="_placeTextY">
if (this._field) {
if (this.multiline) {
this._field.setAttribute('y', 2);
} else {
this._field.setAttribute('y', (this.height - this._field.fontsize) / 2 - 3);
}
}
</method>
<method name="init">
super.init();
// Make sure the initial rollback value is "", not "null"
this.rollbackvalue = "";
// Check to see if we have to set text during init.
if ( this['_initialtext'] != null ){
this.doSetValue( this._initialtext, true, false );
}
// Make sure value and text are in sync
this.value = this.text;
// Check to see if we have to place text during init.
if (this[ '_initialtexty' ] ) {
this._placeTextY()
}
if (this._field) { // if you instantiate a baseedittext,
// it will not have an _field
if (this.multiline != this._field.multiline) {
this._field.setAttribute("multiline", this.multiline);
}
if (this.maxlength != null) {
this._field.setAttribute('maxlength', this.maxlength);
}
if (this.pattern != null) {
this._field.setAttribute('pattern', this.pattern);
}
}
</method>
<method name="setText" args="t,isinitvalue=false">
if (! isinitvalue) {
if ($debug) {
Debug.deprecated(this, arguments.callee, this.setAttribute);
}
}
this.doSetValue(t,isinitvalue, false);
</method>
<method name="acceptValue" args="data, type=null">
if (type == null) type = this.type;
this.doSetValue(lz.Type.acceptTypeValue(type, data, this, 'value'), true, false);
</method>
<method name="doSetValue" args="value,isinitvalue,_ignorecalldown">
//----------------------------------------------------------------
// @param Boolean _ignorecalldown: if true, means that setValue
// should not call internal inputtext since that's what called
// setValue. This is a private parameter that should only be used
// by internalinputtext.
//----------------------------------------------------------------
if (this._initcomplete) {
if (! _ignorecalldown) {
if (this._field) {
// Have to set internal inputtext's nocallback attr. It
// can't be passed into _field.setAttribute('text', ) since it's not an
// laszlo method. Nocallback means that setValue called
// internal inputtext and inputtext should not call setValue
// back.
this._field.ignorecallup = true;
// _internalinputtext's ontext will trigger an ontext and
// onvalue event so we don't send those events here.
this._field.setAttribute('text', value);
}
}
this.text = value;
// It's important to call super.setValue *after* setting text to value,
// because super.setValue may send an event that other components listen
// to, and so the invariant that text = value must hold here.
super.setValue(value,isinitvalue);
if (this['ontext']) this.ontext.sendEvent(value);
} else {
if (this._initialtext == '' || this._initialtext == null) {
this._initialtext = value;
}
}
</method>
<method name="clearText" args="isinitvalue">
this.doSetValue('', isinitvalue, false);
</method>
<method name="setMaxlength" args="n">
this.setAttribute('maxlength', n);
this._field.setMaxlength(n);
</method>
<method name="setSelection" args="start,end=null">
this._field.setSelection(start, end);
</method>
<method name="getSelectionPosition">
return this._field.getSelectionPosition();
</method>
<method name="getSelectionSize">
return this._field.getSelectionSize();
</method>
<method name="setPattern" args="r">
if ($debug) {
Debug.deprecated(this, arguments.callee, this.setAttribute);
}
this.setAttribute('pattern', r);
</method>
<event name="onpattern"/>
<setter name="pattern" args="r">
this.pattern = r;
if (this.onpattern.ready) { this.onpattern.sendEvent(r); }
if (this._initcomplete) {
this._field.setAttribute('pattern', r);
}
</setter>
<method name="getValue">
if (this._initcomplete) {
return (this._field ? this._field.text : "");
} else {
return this._initialtext;
}
</method>
<method name="getText">
if (this._initcomplete) {
return (this._field ? this._field.text : "");
} else {
return this._initialtext;
}
</method>
<method name="_showEnabled">
this._field.setAttribute('enabled', this._enabled);
</method>
<method name="_applystyle" args="s">
if (this.style != null) {
if (this.bgcolor) {
this._field.setAttribute('bgcolor',s.textfieldcolor);
}
if (this['_face']) {
this._face.setAttribute('bgcolor',s.textfieldcolor);
}
}
</method>
</class>
</library>
Cross References
Includes
Classes