[Pas2js] is it possible to create GUi with no need to manually add the code to .html page

Jean SUZINEAU Jean.Suzineau at wanadoo.fr
Tue Aug 25 23:45:48 CEST 2020


Le 25/08/2020 à 21:18, Mgr. Janusz Chmiel a écrit :
> Here is The code, but Browser still show empty page.

It's very funny.

I've just run the program with the debugger in the navigator (F12 key in 
Firefox), running step by step the program.

In fact the button is created ... but it disappears when running 
Terminate and Application.Free, which is logic, anyway.

Here is my test code, with Terminate and Application.Free commented.

program project1;

{$mode objfpc}

uses
     browserapp, JS, Classes, SysUtils, Web, webwidget, htmlwidgets;

type
  TMyApplication
  =
   class(TBrowserApplication)
     procedure doRun; override;
   end;


procedure TMyApplication.doRun;
var
    FMyPage: TWebPage;
    FMyButton: TButtonWidget;
begin
      WriteLn('TMyApplication.doRun;');

      FMyPage:=TWebPage.Create(Self);
      FMyPage.Parent:=TViewPort.Create(Nil);


      FMyButton:=TButtonWidget.Create(Self);
      FMyButton.Parent:=FMyPage;
      FMyButton.Text:='Start The code';
      FMyButton.Refresh;

      FMyPage.Refresh;
      //Terminate;
end;

var
    Application : TMyApplication;

begin
     Application:=TMyApplication.Create(nil);
     Application.Initialize;
     Application.Run;
     //Application.Free;
end.





More information about the Pas2js mailing list