HTMLView: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
Line 42: Line 42:
   SetTimeout(HTMLview1_ref.refresh(),100)
   SetTimeout(HTMLview1_ref.refresh(),100)
End Function
End Function
</pre>
Scroll to the bottom of the HTMView (BASIC or JavaScript)
<pre>
  HTMLview1_ref.scrollTo(0,-HTMLview1.clientHeight)
</pre>
</pre>



Revision as of 14:46, 7 June 2013

Description

The HTMLView control is used to display html formatted text. The view can be scrolled in the window by using a finger.

To add an HTMLView to your app, choose the HTMLView icon in the Toolbar. Use the Property Editor to set the properties. The onclick event can be used to check for clicks.

If you want to have your view scroll, turn scrolling on. After the view has been drawn, you need to set the scroller by doing HTMLview1.refresh(). If you have images you wish to scroll, their height and width need to be specified.

Methods and Properties

Standard properties are supported, plus:

borderStyle The style of the border around the view. Choices are dotted, dashed, solid, double, groove, ridge, inset and outset.
innerHTML The initial contents of the control. Almost any HTML is allowed, including text markup, images and URL’s. However, care must be taken that the HTML is valid. For example, forgetting to match a <div> or <font> tag with a matching </div> or </font> tag will cause other problems in your project.
refresh() Recalculate the size of the scrolling area after area has been updated.
scrolling On/off. Controls whether the contents can be scrolled.
scroll_options This control makes use of iScroll. It has a number of options, including:

bounce: true/false. When the end of the scroll area is reached, should the image bounce?

zoom: true/false. Allow two finger zoom in gesture?

The full list of options is documented here: http://cubiq.org/iscroll-4

Events

HTMLView supports the standard events.

Example (Basic)

Function Button1_onclick()
  HTMLview1.innerHTML=HTMLview1.innerHTML & "<br>Len is now" & _ Len(HTMLview1.innerHTML)
  SetTimeout(HTMLview1_ref.refresh(),100)
End Function

Scroll to the bottom of the HTMView (BASIC or JavaScript)

  HTMLview1_ref.scrollTo(0,-HTMLview1.clientHeight)

Example (JavaScript)

Button1.onclick = function() {
  HTMLview1.innerHTML=HTMLview1.innerHTML + "<br>Len is now"
  HTMLview1.innerHTML += HTMLview1.innerHTML.length;
  setTimeout(HTMLview1_ref.refresh(),100);
}

Output

(as seen in the image above)