Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    HTMLPanel with maximum height and scrolling

    I have an HTMLPanel contained in a VLayout. My desired behavior is that the HTMLPanel will automatically expand its height to show the HTML content to some maximum height. Once the height of the content exceeds a maximum height, the HTMLPanel will have scrollbars and allow the HTML content to be viewed using the scroll bars.

    I have tried a few settings as illustrated by this code:

    Code:
     
     
        [B]enum[/B] HeightSetting {
            [B][I]SET_HEIGHT[/I][/B],
            [B][I]AUTO_HEIGHT[/I][/B],
            [B][I]HEIGHT100[/I][/B]
        }
     
        [B]public[/B] HTMLPaneTest() {
     
            setAutoHeight();
     
            setWidth(900);
     
            HTMLPane htmlPane = [B]new[/B] HTMLPane();
            htmlPane.setShowEdges([B]true[/B]);
            htmlPane.setContentsURL("responder/001.html");
            htmlPane.setContentsType(ContentsType.[B][I]PAGE[/I][/B]);
            htmlPane.setWidth100();
     
            HeightSetting heightSetting = HeightSetting.[B][I]SET_HEIGHT[/I][/B];
     
            [B]switch[/B] (heightSetting) {
     
            [B]case[/B] [B][I]AUTO_HEIGHT[/I][/B]:
                htmlPane.setAutoHeight();
                [B]break[/B];
     
            [B]case[/B] [B][I]HEIGHT100[/I][/B]:
                htmlPane.setHeight100();
                [B]break[/B];
     
            [B]case[/B] [B][I]SET_HEIGHT[/I][/B]:
                htmlPane.setHeight(700);
                [B]break[/B];
     
            }
     
            addMember(htmlPane);
     
        }
     
    }
    The only setting that I have tried that causes the HTMLPanel to display the HTML contents is setting the height to a specific value. Using setAutoHeight or setHeight100 causes nothing to be displayed other that border surrounding zero height.

    What settings can I used to achieve my desired display behavior?




    #2
    The behavior you're looking for is not currently supported out of the box.

    There are 2 issues here.
    The Canvas <i>autoHeight</i> feature is intended for use with Overflow.VISIBLE components only - essentially the component will size down to a very small default height, and the standard overflow behavior will cause it to expand to accomodate the content.
    There is not currently a built in mechanism to have the component expand to some specified maximum at which point scrollbars are introduced.

    Secondly - for an HTMLFlow with contentsType set to "page", we load a full HTML page into an iframe. This approach is not compatible with Overflow.VISIBLE.

    If your target HTML could be loaded as a fragment rather than a page, an option would be to set overflow to Overflow.AUTO initially and size to the desired maximum.
    When the content has loaded you could examine the scrollHeight of the page, and if it is less than the desired maximum explicitly resize the handle smaller (possibly by setting overflow to Overflow.VISIBLE and resizing down to a very small height).

    Regards
    Isomorphic Software

    Comment

    Working...
    X