Name

basescrollbar — Provides non-visual aspects of scrollbar.

Synopsis

LZX: basescrollbar
JavaScript: lz.basescrollbar
Type: Class
Access: public
Topic: Components.Base Components
Declared in: lps/components/base/basescrollbar.lzx

Description

If you want to create a scrollbar with a custom look, you can use basescrollbar along with helper classes basescrolltrack, basescrollthumb, and basescrollarrow. These classes will allow you to change resources, colors, and the position or presence of various elements.

Example 24. An unconventional scrollbar

<canvas height="120" bgcolor="silver" maxtextheight="700">
              <class name="myscrollbar" extends="basescrollbar" width="20">
                <view name="scrolltrack" width="100%" options="releasetolayout">
                  <basescrolltrack x="5" direction="-1" width="${parent.width-10}" height="${parent.thumb.y}" bgcolor="yellow"/>
                  <basescrollthumb name="thumb" x="1" width="${parent.width-2}" bgcolor="green"/>
                  <basescrolltrack x="5" direction="1" y="${parent.thumb.y+parent.thumb.height}" width="${parent.width-10}" height="${parent.height - parent.thumb.y - parent.thumb.height}" bgcolor="yellow"/>
                </view>
            
                <basescrollarrow direction="-1" x="2" bgcolor="yellow">
                    <text>up</text>
                    </basescrollarrow>
            
                <basescrollarrow direction="1" x="2" bgcolor="yellow">
                  <text>dn</text>
                  </basescrollarrow>
                <resizelayout spacing="4"/>
              </class>
            
              <view x="10" y="10" bgcolor="white" width="200" height="100" clip="true">
                <text multiline="true" width="180">
                  Man through his scientific genius has been able to draw distance and
                  save time and space. He has been able to carry highways through the
                  stratosphere. We read just the other day that a rocket plane went 1900
                  miles in one hour. Twice as fast as the speed of sound. This is the
                  new age. Bob Hope has described this new age, this jet age; it is an
                  age in which planes will be moving so fast that we will have a
                  non-stop flight from New York to Los Angeles, when you start out you
                  might develop the hiccups and you will hic in New York and cup in Los
                  Angeles. This is an age in which it will be possible to leave Tokyo on
                  a Sunday morning and arrive in Seattle, Washington on the preceding
                  Saturday night. When your friends meet you at the airport and ask what
                  time did you leave Tokyo, you will have to say I left tomorrow. That
                  is this new age.  We live in one world geographically. We face the
                  great problem of making it one spiritually.
                  <br/>
                  Through our scientific means we have made of the world a
                  neighborhood and now the challenge confronts us through our
                  moral and spiritual means to make of it a brotherhood. We must
                  live together, we are not independent we are interdependent. We
                  are all involved in a single process. Whatever affects one
                  directly affects all indirectly for we are tied together in a
                  single progress. We are all linked in the great chain of
                  humanity.
                  <br/>
                  Martin Luther King, Jr.
                  <br/>
                  11 August 1956
                </text>
                <myscrollbar/>
              </view>
            </canvas>

Scrollbar arrows are optional or may be placed anywhere within the scrollbar. The thumb and track elements expect to be inside a view named scrolltrack. It may seem odd that the scrolltrack is placed twice, but this allows a more flexible appearance as well as particular behaviors that you may want to trigger differently when the user clicks the track to scroll up or down.

For another example of using basescrollbar, you can look at lps/components/lz/scrollbar.lzx to see the code for the lz scrollbar class. An easy way to make your own scrollbar is to copy that file and replace resources and modify attributes or views to suit your design goals.

Contains non-visual aspects of a scrollbar. Subclasses are expected to define this.thumb and this.scrolltrack to reference the views that perform those functions.

Superclass Chain

node (LzNode) » view (LzView) » basecomponent » basescrollbar

Known Subclasses

Details

Properties (15)

axis
<attribute name="axis" type="string" value="y" />
public final var axis : String;
Axis may be "x" or "y", controls the orientation and default scrollattr, default: "y"
_enabled
<attribute name="_enabled" value="${this.enabled && this.scrollable && (this._parentcomponent ? this._parentcomponent._enabled : true)}" />
private var _enabled;
focusview
<attribute name="focusview" value="null" />
public var focusview;
The view to which the scrollbar should listen for mousewheel activation events. If not set, it will be set to the scrolltarget or the immediateparent of the scrollbar, whichever is focusable
mousewheelactive
<attribute name="mousewheelactive" type="boolean" value="false" />
public var mousewheelactive : boolean;
If true, the mousewheel is active for the focusview. read-only
mousewheelevent_off
<attribute name="mousewheelevent_off" type="string" value="onblur" />
public var mousewheelevent_off : String;
The event that deactivates the mousewhen when sent from the focusview
mousewheelevent_on
<attribute name="mousewheelevent_on" type="string" value="onfocus" />
public var mousewheelevent_on : String;
The event that activates the mousewhen when sent from the focusview
othersb
<attribute name="othersb" value="0" />
private var othersb;
Reference to the other scrollbar, if there is one. This value is set oninit.
pagesize
<attribute name="pagesize" type="number" value="null" />
public final var pagesize : Number;
The maximum distance to scroll, default: the height or width of the scrollbar.
scrollable
<attribute name="scrollable" value="true" />
public read-only var scrollable;
True if the scrolltarget is bigger than the containing view therefore the scrollbar is active. The scrollbar appears disabled when scrollable is false. You can make the scrollbar invisible when there is nothing to scroll by setting visible="${scrollable}"
scrollattr
<attribute name="scrollattr" type="string" value="" />
public final var scrollattr : String;
The attribute of the scrolltarget that is modified by the scrollbar, default: value of axis attribute.
scrollmax
<attribute name="scrollmax" type="number" value="null" />
public var scrollmax : Number;
The maximum distance to scroll, default: the height or width of the scrolltarget.
scrolltarget
<attribute name="scrolltarget" type="expression" value="0" />
public final var scrolltarget : Object;
The view that is controlled by the scrollbar.
stepsize
<attribute name="stepsize" value="10" />
public var stepsize;
The amount that the scrolltarget is moved when the user clicks on the scrolltrack or when the step method is called, default: 10.
usemousewheel
<attribute name="usemousewheel" value="true" />
public var usemousewheel;
If true, this scrollbar listens for mousewheel events
usetargetsize
<attribute name="usetargetsize" value="false" />
private var usetargetsize;
If scrollmax is not defined and this is true, use the target height or width to determine scrollmax, default: false.

Methods (15)

activateMouseWheel()
<method name="activateMouseWheel" />
private function activateMouseWheel();
_applystyle()
<method name="_applystyle" args="s" />
private function _applystyle(s);
deactivateMouseWheel()
<method name="deactivateMouseWheel" />
private function deactivateMouseWheel();
destroy()
<method name="destroy" />
private function destroy();
init()
<method name="init" />
private function init();
mousewheelUpdate()
<method name="mousewheelUpdate" args="d" />
private function mousewheelUpdate(d);
page()
<method name="page" args="n" />
public function page(n : Number);
Page(1) to page ahead, page(-1) to page back.
scrollbarSizeUpdate()
<method name="scrollbarSizeUpdate" />
private function scrollbarSizeUpdate();
setPosRelative()
<method name="setPosRelative" args="change" />
private function setPosRelative(change);
_showEnabled()
<method name="_showEnabled" />
private function _showEnabled();
Subclasses can override to change visual state when the scrollable attribute changes state.
step()
<method name="step" args="n" />
public function step(n : Number);
Step(1) to move ahead, step(-1) to move back.
targetPosUpdate()
<method name="targetPosUpdate" />
private function targetPosUpdate();
targetSizeUpdate()
<method name="targetSizeUpdate" />
private function targetSizeUpdate();
updateThumbPos()
<method name="updateThumbPos" />
private function updateThumbPos();
updateThumbSize()
<method name="updateThumbSize" />
private function updateThumbSize();

Events (2)

onscrollable
<attribute name="onscrollable" />
private event onscrollable;
onscrollmax
<attribute name="onscrollmax" />
public event onscrollmax;

LZX Synopsis

<class name="lz.basescrollbar" extends=" lz.basecomponent ">
  <attribute name=" axis " type="string" value="y" />
  <attribute name=" _enabled " value="${this.enabled && this.scrollable && (this._parentcomponent ? this._parentcomponent._enabled : true)}" />
  <attribute name=" focusview " value="null" />
  <attribute name=" mousewheelactive " type="boolean" value="false" />
  <attribute name=" mousewheelevent_off " type="string" value="onblur" />
  <attribute name=" mousewheelevent_on " type="string" value="onfocus" />
  <attribute name=" othersb " value="0" />
  <attribute name=" pagesize " type="number" value="null" />
  <attribute name=" scrollable " value="true" />
  <attribute name=" scrollattr " type="string" value="" />
  <attribute name=" scrollmax " type="number" value="null" />
  <attribute name=" scrolltarget " type="expression" value="0" />
  <attribute name=" stepsize " value="10" />
  <attribute name=" usemousewheel " value="true" />
  <attribute name=" usetargetsize " value="false" />
  <method name=" activateMouseWheel " />
  <method name=" _applystyle " args="s" />
  <method name=" deactivateMouseWheel " />
  <method name=" destroy " />
  <method name=" init " />
  <method name=" mousewheelUpdate " args="d" />
  <event name=" onscrollable " />
  <event name=" onscrollmax " />
  <method name=" page " args="n" />
  <method name=" scrollbarSizeUpdate " />
  <method name=" setPosRelative " args="change" />
  <method name=" _showEnabled " />
  <method name=" step " args="n" />
  <method name=" targetPosUpdate " />
  <method name=" targetSizeUpdate " />
  <method name=" updateThumbPos " />
  <method name=" updateThumbSize " />
</class>

JavaScript Synopsis

public lz.basescrollbar extends  lz.basecomponent  {
  public final var axis  : String;
  private var _enabled ;
  public var focusview ;
  public var mousewheelactive  : boolean;
  public var mousewheelevent_off  : String;
  public var mousewheelevent_on  : String;
  private var othersb ;
  public final var pagesize  : Number;
  public read-only var scrollable ;
  public final var scrollattr  : String;
  public var scrollmax  : Number;
  public final var scrolltarget  : Object;
  public var stepsize ;
  public var usemousewheel ;
  private var usetargetsize ;
  prototype private function activateMouseWheel ();
  prototype private function _applystyle (s);
  prototype private function deactivateMouseWheel ();
  prototype private function destroy ();
  prototype private function init ();
  prototype private function mousewheelUpdate (d);
  prototype private event onscrollable ;
  prototype public event onscrollmax ;
  prototype public function page (n : Number);
  prototype private function scrollbarSizeUpdate ();
  prototype private function setPosRelative (change);
  prototype private function _showEnabled ();
  prototype public function step (n : Number);
  prototype private function targetPosUpdate ();
  prototype private function targetSizeUpdate ();
  prototype private function updateThumbPos ();
  prototype private function updateThumbSize ();
}