Welcome, Guest
Username: Password: Remember me
CodeTyphon Web Development Pas2JS, WASM, etc, discussions and problems
  • Page:
  • 1

TOPIC:

pas2js create web components at runtime 2 years 4 months ago #16327

  • Michael
  • Michael's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 5
  • Thank you received: 0
Dear all,

I am very happy, that the web components and the pas2js transpiler made it into Code Typhon. I use Ubuntu 20.04, on x86.64, with CT 7.7. I looked on the 3 example project with the web components. This looks all very interesting.
But I am not able, to create new components at runtime. Well, the compiler accept all, but no components become visible in the browser app. For example:
     wLbl1 := TWLabel.Create(WForm1); //WForm1 is TWForm
     wLbl1.Left := 410;
     wLbl1.Top := 115;
     wLbl1.Caption:= 'Hallo';
     wLbl1.Parent := WForm1; 

With VCL application, calling the constructor, and then setting the Parent property was all what was needed. How can the same thing be done with the web components in the Browser/Javascript?

I would like to develop some web DB-aware components.
One more thing: When inheriting web components to make new components, the overwritten constructor is not called. I guess, there is some magic, how the pas2js and the jQuery Javascript library are working together. What is the suggested way?
Any help is welcomed.

regards,
 

Please Log in or Create an account to join the conversation.

pas2js create web components at runtime 2 years 4 months ago #16328

  • Matis A.
  • Matis A.'s Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1060
  • Thank you received: 149
Put your code onShow of main WForm

procedure TWForm1.FormShow(Sender: TObject);
begin
    wLbl1 := TWLabel.Create(WForm1); //WForm1 is TWForm   
     wLbl1.Parent := WForm1;   // Parent always after Create
     wLbl1.Left := 410;
     wLbl1.Top := 115;
     wLbl1.Caption:= 'Hallo from CT';
end;             

For "overwritten constructor" I need some code sample.

This ability of CT, Web GUI app, it's new.
I hope for more components. 
 
PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Matis A..

pas2js create web components at runtime 2 years 4 months ago #16389

  • Michael
  • Michael's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 5
  • Thank you received: 0
a test showed, the components created in the "OnShow", as you suggested, worked so far. Also the constructor is executed. So you can close this issue.
Thank you for your fast help.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1