[Pas2js] is it possible to create GUi with no need to manually add the code to .html page
Michael Van Canneyt
michael at freepascal.org
Mon Aug 24 17:55:43 CEST 2020
On Mon, 24 Aug 2020, Mgr. Janusz Chmiel wrote:
> When I have looked at Pacman demo and inside some other demos, I have sadly
> found out, that HTMl code contain code to create some buttons, and when some
> HTMl element is selected, Javascript react on it, so Pascal source contain
> The appropriate code.
> Is it possible to use webwidgets.pas unit to create GUi elements such as.
> Combobox, rfadio button, checkbox, ETC? Or I would also had to create those
> elements first inside .html code and react on its events from Pascal source?
You can do both.
> Or webwidget unit can be also used to create GUi elements on WEB page with
> no need to add new data to .html file? So everything can be done directly
> from .pas or .lpr sources?
You can do both.
FMyPage:=TWebPage.Create(Self);
FMyButton:=TButtonWidget.Create(Self);
FMyButton.Parent:=FMyPage;
FMyButton.Text:='Click me';
Or you can put the page and button in the HTML like this:
<div id="mydivid">
<button id="mybuttonid" type="button" class="btn btn-primary">Click me</button>
</div>
and do
FMyPage:=TWebPage.Create(Self);
FMyPage.ElementID:='mydivid'; // Some div
FMyButton:=TButtonWidget.Create(Self);
FMyButton.ElementID:='mybuttonid';
The end effect is the same.
Michael.
More information about the Pas2js
mailing list