📄 scrollbartest2.xml
字号:
<?xml version="1.0"?><Application autoNameMapping="true"> <Window caption="ScrollBar Test 2" width="300" height="300"> <Command id="append" onexecute="area.appendText(text.getText())"/> <Label left="5" top="5" text="Text to append:"/> <TextField id="text" left="5" right="70" top="20" command="append"/> <RepeatButton right="5" top="19" width="60" command="append" text="Append"/> <ScrollArea id="area" left="5" right="5" top="50" bottom="5"/> </Window> <Resources> <Script><![CDATA[// create a scroll areafunction ScrollArea() { BiComponent.call( this ); // create the label where the text will be stored this._label = new BiLabel(); this._label.setLeft( 0 ); this._label.setRight( 16 ); this._label.setTop( 0 ); this._label.setBottom( 16 ); this._label.setBackColor( "white" ); this._label.setWrap( true ); this._label.setCanSelect( true ); // create the vertical scroll bar this._vScroll = new BiScrollBar( "vertical" ); this._vScroll.setUnitIncrement( 13 ); // one row is 13px this._vScroll.setRight( 0 ); this._vScroll.setTop( 0 ); this._vScroll.setBottom( 16 ); this._vScroll.setMaximum( 0 ); this._vScroll.addEventListener( "change", function ( e ) { this._label.setScrollTop( this._vScroll.getValue() ); }, this ); // create the horizontal scroll bar this._hScroll = new BiScrollBar( "horizontal" ); this._hScroll.setUnitIncrement( 13 ); // one row is 13px this._hScroll.setLeft( 0 ); this._hScroll.setRight( 16 ); this._hScroll.setBottom( 0 ); this._hScroll.setMaximum( 0 ); this._hScroll.addEventListener( "change", function ( e ) { this._label.setScrollLeft( this._hScroll.getValue() ); }, this ); this.add( this._label ); this.add( this._vScroll ); this.add( this._hScroll ); this.setBorder( new BiBorder( 2, "inset" ) ); this.addEventListener( "create", this._adjustScrollBars, this ); this.addEventListener( "resize", this._adjustScrollBars, this );}_p = ScrollArea.prototype = new BiComponent();_p._className = "ScrollArea";_p.appendText = function ( sText ) { this._label.setText( this._label.getText() + sText ); this._adjustScrollBars();// this._vScroll.setValue( 9999 );}_p._adjustScrollBars = function () { var vMax = this._label.getScrollHeight(); var hMax = this._label.getScrollWidth(); var vExtent = this._label.getHeight(); var hExtent = this._label.getWidth(); if ( vMax < vExtent ) { vExtent = vMax; } if ( hMax < hExtent ) { hExtent = hMax; } if ( this._vScroll.getValue() > vMax - vExtent ) { this._vScroll.setValue( vMax - vExtent ); } if ( this._hScroll.getValue() > hMax - hExtent ) { this._hScroll.setValue( hMax - hExtent ); } this._vScroll.setMaximum( vMax ); this._hScroll.setMaximum( hMax ); this._vScroll.setExtent( vExtent ); this._hScroll.setExtent( hExtent );} ]]></Script> </Resources></Application>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -