简体   繁体   中英

OpenLaszlo scrolling issue

I am having a view like mentioned below and i am adding lot of views dynamically to the contents view and the problem is scrollbar is not getting visible. So i drilled down aa bit and i found that the content's height is not getting updated after i have added the views dynamically.

What am i doing wrong here? The same code is working properly in Openlaszlo 3.3

<view name="wrapper">
 <view name="scrollablecontainer"
                  width="${this.contentwrapper.width &gt; parent.width
                         ? this.contentwrapper.width : parent.width}"
                  height="${this.contentwrapper.height &gt; parent.height 
                          ? this.contentwrapper.height : parent.height}">
                <view name="contentwrapper" >
                    <view name="contents"/>
                </view>
  </view>
 <vscrollbarnew name="vscroll"
                        height="${this.height}"
                        pagesize="${this.height}"
                        visible="${this.scrollable}"/>
</view>

I missed out one thing when the component initializes i am setting contentwrapper width and height to 0.

Runtime : swf Test browser: firefox, windows xp

Your structure looks very complicated. Why do you have a contentwrapper and a contents view. I've created an example which compiles in both OpenLaszlo 3.4 (swf7 and swf8) and OpenLaszlo 5.0 trunk (SWF10 and DHTML). I've set clipping to true on the wrapper view and added a layout to the view scrollablecontainer into which the dynamically created views will be added.

<canvas height="400">

    <attribute name="counter" type="number" value="0" />

    <class name="rectangle" width="200" height="30" bgcolor="blue">
        <text name="label" align="center" valign="middle" />
    </class>

    <!-- Wrapping view needs to have a width and height set and clip set to true -->
    <view name="wrapper" x="100" y="10"
          width="236" height="150"
          bgcolor="#ff9999"
          clip="true">

        <view x="10" name="scrollablecontainer"
              bgcolor="#aaaaaa">

            <simplelayout axis="y" spacing="8" />

        </view>

        <vscrollbar name="vscroll"
                    visible="${this.scrollable}"/>
    </view>

    <method name="addView">
        var v = null;
        if ( $swf7 || $swf8 ) {
            v = new rectangle( canvas.wrapper.scrollablecontainer );
        } else {
            v = new lz.rectangle( canvas.wrapper.scrollablecontainer );
        }
        canvas.counter++;
        v.label.setAttribute( 'text', 'View #' + canvas.counter );
    </method>

    <view>
        <checkbox value="true" onvalue="canvas.wrapper.setAttribute('clip', this.value)" />
        <text x="20" >Clipping of view 'wrapper'</text>
    </view>

    <button y="25" text="Add view" onclick="canvas.addView()" />

</canvas>

The view named wrapper should have clipping enabled, and needs to have a value set for width and height. By clicking the checkbox you can toggle the value of the clip attribute for the wrapper to see the effect.

Here's the app running in OpenLaszlo 5.0 trunk SWF10: OpenLaszlo滚动条和动态视图生成

And here the same code running in OpenLaszlo 3.4 SWF8: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM