April 20, 2013

New in Smart 1.1: HTML Elements

Smart Mobile Studio 1.1 contains many new controls which I hope to describe in the following days. Today I’ll start with a group of three controls which allow the programmer to insert specific HTML elements (a.k.a. tags) on a Smart form.

image

The usage is simple. You drop a a control on a form, resize it to an appropriate size and write few lines of code.

image
procedure TForm1.InitializeObject;
begin
inherited
;
{$I 'Form1:impl'}
W3IFrameHtmlElement1.Src := 'http://www.youtube.com/embed/WcLrcFPBK7c'
;
W3DIVHtmlElement1.InnerHTML := 'div element'
;
W3PREHtmlElement1.InnerHtml := 'pre element'
;
end
;

To set content for the DIV and PRE elements you simply assign a string to the InnerHTML property. A source location for the IFrame element is set by assigning to the Src property.


image

If you check the document contents, you’ll see that there are indeed an iframe, div and pre elements on the form.

image

You can download the code at www.gabrijelcic.org/Smart/HTMLElements/HTMLElements.opp and test it at www.gabrijelcic.org/Smart/HTMLElements/bin/index.html.

3 comments:

  1. When i test this on my android Phone i get a
    TypeError.'window.webkitReguestAnimationFrame '

    ReplyDelete
  2. This is a known problem in Smart 1.1 - programs don't work on Android, Opera and iOS 5.x.

    The fix for that was committed today and Smart 1.1 hotfix 1 should be released early this week.

    ReplyDelete
    Replies
    1. I have rebuilt the code at www.gabrijelcic.org with the fixed compiler and now it should work in Android and other affected devices.

      Delete