Lazarus+fpc.3.0.4 (tested with 3.2.0 beta also - same results) on Windows 10.
Simple application with just main form with one button and memo.
if FormShow() WebMemo1.Lines.Add('Application.Assigned=' + BoolToStr(Assigned(Application), True));
WebButton1.OnClick does not work - set OnClick and put ShowMessage('hello world) inside event.
Start app, click button does not work. Firefox console shows errors....
inside project1.lpr, just before Aplication.Run (after Application.CreateForm(TMyFormClass, frmMyForm) provoke error with eg if not Assigned(frmMyForm) then raise;
Now everything works ok. Of course firefox console shows one error about raise but application works.
Is this bug or I'm doing something wrong. Unfortunatelly I cannot attach simple example project here.
Forgot to mention WebCore version. It's 1.2.6.0
Even with 1.2.7.0 simple application does not work under lazarus :( . If I add raise; before application.run then it works ok. Anyone have similar problems with lazarus ?
What exact console error do you see when you call the ShowMessage()?
Now I've found "the way". Removed Application.Free; after Application.Run and everything works fine.
This is error without my workaround:
applicationtest.js:8167 Uncaught TypeError: Cannot read property 'FMainForm' of null
at Object.ShowMessage (applicationtest.js:8167)
at Object.WebButton1Click (applicationtest.js:9356)
at Object.cb [as FOnClick] (applicationtest.js:222)
at Object.Click (applicationtest.js:4857)
at Object.HandleDoClick (applicationtest.js:4498)
at HTMLButtonElement.cb (applicationtest.js:222)
Also I cannot download 1.2.7.1 atm since I've downloaded 1.2.7.0 today,so cannot test if that matters.Download is blocked for 24hrs ....
The download counter was reset.
simple project test
program applicationtest;
{$mode delphi}
uses
WEBLib.Forms, mainproject;
begin
Application.Initialize;
Application.MainFormOnTaskBar:=True;
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
{now it works Application.Free;}
end.
#mainproject.pas
unit mainproject;
{$mode delphi}
interface
uses
SysUtils, Classes, WEBLib.Forms, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Dialogs, WEBLib.StdCtrls, WEBLib.ExtCtrls;
type
{ TfrmMain }
TfrmMain = class(TWebForm)
WebButton1: TWebButton;
WebLabel1: TWebLabel;
lbTime: TWebLabel;
WebMemo1: TWebMemo;
WebTimer1: TWebTimer;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure WebButton1Click(Sender: TObject);
procedure WebTimer1Timer(Sender: TObject);
private
public
end;
var
frmMain: TfrmMain;
implementation
{$R *.lfm}
{ TfrmMain }
procedure TfrmMain.WebButton1Click(Sender: TObject);
begin
ShowMessage('WebButton1Click ...');
end;
procedure TfrmMain.WebTimer1Timer(Sender: TObject);
begin
//lbTime.Caption := FormatDateTime('hh:nn:ss',Now());
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
lbTime.Caption := Self.Name;
// FormatDateTime('hh:nn:ss',Now());
WebMemo1.Lines.Clear;
end;
procedure TfrmMain.FormShow(Sender: TObject);
begin
WebMemo1.Lines.Add(Format('Application assigned ? %s',[BoolToStr(Assigned(Application), True)]));
end;
end.
Thanks :)