[Pas2js] some thoughts about htmlwidgets
Michael Van Canneyt
michael at freepascal.org
Sun Oct 11 23:06:59 CEST 2020
On Sun, 11 Oct 2020, Mgr. Janusz Chmiel wrote:
> I Am now doing my best to inject The code TEventTableWidgetDemo on a empty
> new project. Which will be able to run separately so I will be able to add
> my Cech question and I will be able to test The answers and everything will
> be as A table.
> I Am sending you my first attempt, code can not be compiled. I would like to
> know if I Am going by right direction, or if I can not do that by using this
> approach.
Your approach is OK. You simply had a typing error in your code.
I completed the code somewhat, so you can see how to proceed,
and I attached your reworked project.
Michael.
-------------- next part --------------
program project1;
{$mode objfpc}
uses
sysutils, web, js, webwidget, htmlwidgets, browserapp;
type
TMyApplication = class(TBrowserApplication)
private
FInputs : Array[0..9] of TTextInputWidget;
FTable : TEventTableWidget;
FWebPage: TWebPage;
procedure DoGetCellData(Sender: TObject; Enum: TTableRowEnumerator; aCell: TTableWidgetCellData);
Public
procedure doRun; override;
end;
procedure TMyApplication.DoGetCellData(Sender: TObject; Enum: TTableRowEnumerator; aCell: TTableWidgetCellData);
begin
if aCell.Kind=rkBody then
case aCell.Col of
0 : aCell.Text:='Question '+IntToStr(aCell.Row+1);
1 :
begin
Finputs[aCell.Row]:=TTextInputWidget.Create(Self);
aCell.Widget:=Finputs[aCell.Row];
end;
end;
end;
procedure TMyApplication.doRun;
begin
FWebPage:=TWebPage.Create(Self);
FTable:=TEventTableWidget.Create(Self);
FTable.OnGetCellData:=@DoGetCellData;
FTable.CustomColumns.Add('Question');
FTable.CustomColumns.Add('Answer');
FTable.Parent:=FWebPage;
FTable.RowCount:=Length(FInputs);
Terminate;
end;
var
Application : TMyApplication;
begin
Application:=TMyApplication.Create(nil);
Application.Initialize;
Application.Run;
end.
More information about the Pas2js
mailing list