scrolledittext.lzx
<library>
<include href="lz/vscrollbar.lzx"/>
<class name="scrolledittext" extends="baseedittext" multiline="true" clip="true" height="100">
<attribute name="border" value="0
"/>
<view name="_face" bgcolor="0xffffff" width="${parent.width-parent.border*2}" height="${parent.height-parent.border*2}" x="${parent.border}" y="${parent.border}"/>
<_newinternalinputtext name="inp" x="${parent.border}" y="${parent.border}" height="${parent.height - parent.border * 2}" width="${parent.width - parent.vscrollwidth - parent.border*2}" scrollevents="true">
<attribute name="maxtextheight" value="${this.lineheight * this.maxscroll}"/>
<attribute name="maxheight" value="${this.height + this.maxtextheight}"/>
<attribute name="pos" value="0
" type="number"/>
<setter name="pos" args="p">
if (this.inited) {
var scroll = 1 - Math.floor(p / this.lineheight);
if (scroll !== this.scroll) {
this.setAttribute('scroll', scroll);
//Debug.info('pos', p, this.scroll)
}
this.pos = p;
if (this.onpos) this.onpos.sendEvent(p);
}
</setter>
<handler name="onscroll" args="IGNORE_THIS_ARG">
this.setAttribute('pos', -this.lineheight * (this.scroll - 1));
</handler>
</_newinternalinputtext>
<attribute name="vscrollwidth" value="0
"/>
<method name="setvscrollwidthfromvisibility" args="v">
this.setAttribute("vscrollwidth", (v ? this._vs.width : 0));
</method>
<attribute name="vscrollbarclassname" type="string" value="vscrollbar
"/>
<attribute name="_vs" value="null
"/>
<method name="ensurevscrollbar">
if (this['_vs'] == null) {
var classname = this.vscrollbarclassname;
if (classname == "") {
classname = "vscrollbar";
}
if ($debug) {
if (typeof(lz[classname]) == "undefined") {
Debug.warn("scrollbarclassname undefined", this);
}
}
if(typeof(lz[classname]) != "undefined"){
this._vs = new lz[classname](this,
{ axis: "y",
scrollattr: "pos",
scrollmax: "0",
scrolltarget: this.inp});
var xDel = new lz.Delegate(this, 'updateX');
xDel.register(this['_vs'], 'onwidth');
xDel.register(this, 'onwidth');
xDel.register(this, 'onborder');
new lz.Delegate(this, 'updateScrollMax', this.inp, 'onscrollheight');
new lz.Delegate(this, 'updateStepSize', this.inp, 'onlineheight');
// call once manually
this.updateX();
this.updateStepSize();
}
}
</method>
<method name="updateX" args="IGNORE_THIS_ARG = null">
if(this['_vs']){
this._vs.setAttribute("x", this.width - this._vs.width );
}
</method>
<method name="updateStepSize" args="IGNORE_THIS_ARG = null">
if(this['_vs']){
this._vs.setAttribute("stepsize", this.inp.lineheight);
}
</method>
<method name="updateScrollMax" args="IGNORE_THIS_ARG = null">
if(this['_vs']){
this._vs.setAttribute("scrollmax", this.inp.scrollheight);
}
</method>
<method name="init">
super.init();
this.ensurevscrollbar();
setvscrollwidthfromvisibility(this['_vs'] ? this._vs.visible : false);
this.myDel = new lz.Delegate(this, "setvscrollwidthfromvisibility", this['_vs'], "onvisible");
</method>
<method name="_placeTextY">
</method>
</class>
</library>
Cross References
Includes
Classes