6

Am i missing something here? I purchased Smart Mobile Studio two days ago, and been trying its features. I would expected that it would at least emulate delphi’s event model. No?

Shouldn't I be able to click on a control and have access to an events tab (as we do for properties), and add a delphi style event, such as OnClick for a Button (which would then be translated into a javascript event). I would expect to see not only the OnClick event in my forms unit, but the button as well. Seems that there is no reference to the button either.

What am i missing?

I see how i can do it at runtime, but i still can’t fugure out how to do it at design time. Can someone please help me?

Runtime...

unit Form1;

interface

uses w3system, w3ctrls, w3forms, w3application;

type
 TForm1=class(TW3form)
 private
 { Private methods }
 FButton : TW3Button;
 protected
 { Protected methods }
 Procedure InitializeObject;override;
 Procedure FinalizeObject;override;
 Procedure StyleTagObject;override;
 end;

Implementation

Procedure TForm1.InitializeObject;
 Begin
 inherited;
 FButton:=TW3Button.Create(Self);
 FButton.Caption:=’Load’;
FButton.OnClick:=procedure (Sender : TObject)
 begin
 //do something
 end;
 End;

Procedure TForm1.FinalizeObject;
 Begin
 inherited;
 End;

Procedure TForm1.StyleTagObject;
 Begin
 inherited;
 StyleClass:=’TW3CustomForm’;
 End;

end.
JakeSays
  • 2,048
  • 8
  • 29
  • 43

1 Answers1

4

As of writing, the smart IDE does not support code generation for delegates (or event objects). But this is scheduled to be added.

It is important to understand that smart does not try to be another delphi. That would ruin the richness of both object pascal and javascript by imposing limitations. Instead the central function of the product is to replace javascript with object pascal - which in turn adds to javascript (things like interfaces, inheritance and more).

At present, writing mobile apps is a bit of a black art. Freepascal users do their work by code only, as does C# developers (although we used to connect to the xcode designer .nib files) and naturally also javascript developers. Smart mobile, while it does require you to write more code, is still way ahead of the average javascript developer.

The time saving factor is that you dont have to write it all using javascript, but rather in a language you already know and love.

Jon Lennart Aasenden
  • 3,920
  • 2
  • 29
  • 44
  • I still don't even see the reference to the button. If i drop a button on the form, I dont see it in the code. Where is it? It seems to me, that if you have a component palette where users can drop controls on the form, there should be a way to see it in the code. No? You can change properties and move it around the form, but you can't resize it on the form....you have to do all this at runtime. Well, i might as well create it at runtime as well, and change the properties (resize, and position) there. I sure hope that better event handling can be added in the future. – JakeSays May 21 '12 at 13:06
  • Sorry, i meant to say that you can resize it at design time, but you might as well do that at runtime as well – JakeSays May 21 '12 at 13:13
  • Hi, on the right in the ide you have a tab called "unit structure". You should see the button listed there. Sometimes you need to refesh (the small button above the tab) the view. The actual definition is inside the {$I 'Form1:impl'} section. The compiler takes the mock layout and generates it in-code. – Jon Lennart Aasenden May 21 '12 at 13:26