Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2023-07

Is it possible to keep the text defined in html for a TWebWidget?

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

Let's say I have this in the html

<button type="button" id="testbutton">Test</button>

and in code

MyButton:=TButtonWidget.Create(self);
MyButton.ElementID:='testbutton';
MyButton.Refresh;
This will remove the text from the button, unless I add
MyButton.Text:='Test'.

Is there a way to keep the original text defined in the html?

This doesn't happen, e.g., with a TDivWidget or a TCheckboxInputWidget (they both keep the original content).

I'm using this version of pas2js

commit abaa86d44662735e31f1a93663f54152cfe334c0 (HEAD -> main, origin/main, origin/HEAD)
Author: Micha?l Van Canneyt
Date: Wed Oct 5 11:04:23 2022 +0200

* ApplyText introduced, properly get/set empty text

Bye

Luca
Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 28 lines
Let's say I have this in the html <button type="button" id="testbutton">Test</button> and in code MyButton:=TButtonWidget.Create(self); MyButton.ElementID:='testbutton'; MyButton.Refresh; This will remove the text from the button, unless I add MyButton.Text:='Test'. Is there a way to keep the original text defined in the html? This doesn't happen, e.g., with a TDivWidget or a TCheckboxInputWidget (they both keep the original content). I'm using this version of pas2js commit abaa86d44662735e31f1a93663f54152cfe334c0 (HEAD -> main, origin/main, origin/HEAD) Author: Micha?l Van Canneyt Date: Wed Oct 5 11:04:23 2022 +0200 * ApplyText introduced, properly get/set empty text

There is currently no way. I'm open for suggestions.

Maybe introduce a new value tmAsIs for textmode, and set textmode to tmAsIs as soon as ElementID is set to a non-empty value.

Michael.

Luca Olivetti
to Michael Van Canneyt

El 7/7/23 a les 15:42, Michael Van Canneyt ha escrit:

Show quoted text 34 lines
On Fri, 7 Jul 2023, Luca Olivetti via Pas2js wrote: > Let's say I have this in the html > > <button type="button" id="testbutton">Test</button> > > and in code > > MyButton:=TButtonWidget.Create(self); > MyButton.ElementID:='testbutton'; > MyButton.Refresh; > > > This will remove the text from the button, unless I add > MyButton.Text:='Test'. > > Is there a way to keep the original text defined in the html? > > This doesn't happen, e.g., with a TDivWidget or a > TCheckboxInputWidget (they both keep the original content). > > I'm using this version of pas2js > > > commit abaa86d44662735e31f1a93663f54152cfe334c0 (HEAD -> main, > origin/main, origin/HEAD) > Author: Micha?l Van Canneyt > Date:?? Wed Oct 5 11:04:23 2022 +0200 > > ??? * ApplyText introduced, properly get/set empty text There is currently no way. I'm open for suggestions.

OK, not a biggie, and I'd have no idea on how to implement it but...

Maybe introduce a new value tmAsIs for textmode, and set textmode to tmAsIs as soon as ElementID is set to a non-empty value.

...I tried to follow the code and I cannot find how a TDivWidget preserves the content while a TButtonWidget nukes it (and, btw, I was wrong about the TCheckBoxInputWidget, since its caption has to be enclosed in a <label>).

Bye

Luca
Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 46 lines
El 7/7/23 a les 15:42, Michael Van Canneyt ha escrit: > > > On Fri, 7 Jul 2023, Luca Olivetti via Pas2js wrote: > >> Let's say I have this in the html >> >> <button type="button" id="testbutton">Test</button> >> >> and in code >> >> MyButton:=TButtonWidget.Create(self); >> MyButton.ElementID:='testbutton'; >> MyButton.Refresh; >> >> >> This will remove the text from the button, unless I add >> MyButton.Text:='Test'. >> >> Is there a way to keep the original text defined in the html? >> >> This doesn't happen, e.g., with a TDivWidget or a >> TCheckboxInputWidget (they both keep the original content). >> >> I'm using this version of pas2js >> >> >> commit abaa86d44662735e31f1a93663f54152cfe334c0 (HEAD -> main, >> origin/main, origin/HEAD) >> Author: Micha?l Van Canneyt >> Date:?? Wed Oct 5 11:04:23 2022 +0200 >> >> ??? * ApplyText introduced, properly get/set empty text > > There is currently no way. I'm open for suggestions. OK, not a biggie, and I'd have no idea on how to implement it but... > > Maybe introduce a new value tmAsIs for textmode, and set textmode to tmAsIs > as soon as ElementID is set to a non-empty value. ...I tried to follow the code and I cannot find how a TDivWidget preserves the content while a TButtonWidget nukes it (and, btw, I was wrong about the TCheckBoxInputWidget, since its caption has to be enclosed in a <label>).

For TDivWidget, aForceEmpty is set to false when calling ApplyText from ApplyWidgetSettings.

But ApplyText does not have this parameter in TButton. A simpler solution is probably to add the parameter in TButton.ApplyText and pass false in ApplyWidgetSettings.

Michael.