epopov
12-29-2003, 10:01 AM
Hi,
how to handle onmouseover event of UP scrollbar button?
antun
01-05-2004, 11:11 AM
OK, this is a little complicated: First of all, there isn't a custom event set up for this at the top level of the scrollbar component (something like an "onmouseupuparrow" event).
That means that you have to set it up yourself. The first thing to do is to figure out where the up arrow is in the view hierarchy of the scrollbar class. Use the debugger interactively to find it. (See here (http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=59) for more on that).
Using the above method, I figured out that the up arrow was called "toparrow".
Next, you might be familiar with the following syntax for setting a method to go off when a referenced view sends out an event:
<method event="onclick" reference="myview.foo.bar">
...
</method>
This won't work in the scrollbar, because the toparrow view is created by a state, which is evaluated at init time (which is too late). Here's the state from the scrollbar source:
redmondscrollbar.lzx:
<state apply="${parent.axis == 'y'}">
A way around this is to manually (using script) create a delegate at init time that listens out for the onmouseup event:
<canvas debug="true">
<view width="120" height="120" clip="true" name="myview">
<text multiline="true" width="100">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam sapien felis, fermentum varius, imperdiet nec, viverra eget, purus. Vestibulum nisl. Cras ante. Pellentesque facilisis luctus quam. Cras auctor. Nulla scelerisque nonummy elit. Ut porta interdum urna. Phasellus iaculis sollicitudin dolor. Proin eu purus a urna nonummy ornare. Nullam sapien. Donec eleifend tincidunt wisi. Duis vitae nibh. Fusce augue ante, dictum ut, cursus vitae, venenatis nec, risus. Duis quis nulla eu urna venenatis dignissim. Proin in elit ut velit lacinia viverra. Phasellus scelerisque. Integer scelerisque, elit nec tincidunt faucibus, ligula purus facilisis metus, at feugiat nulla magna sed ligula. Vivamus nec nibh. Nulla tincidunt.
</text>
<scrollbar id="foo">
<method event="oninit">
new LzDelegate( parent, 'scrollarrowup', toparrow,
'onmouseup' );
</method>
</scrollbar>
<method name="scrollarrowup">
Debug.write( "onmouseup event in button" );
</method>
</view>
</canvas>
Remember that you're effectively delving into the view hierarchy of a component. That's the equivalent of calling private methods and accessing private properties of a class. If the scrollbar was to change internally with a new release of the LPS (which in fact it has already, since you can download the 2.0 release already, and the scrollbar that ships with that is not the same as my code is based on).
-Antun
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.