[Pas2js] fieldset (or other tag) change the disabled attribute

Luca Olivetti luca at ventoso.org
Tue Sep 27 13:47:46 CEST 2022


El 13/9/22 a les 16:33, Michael Van Canneyt ha escrit:

> The correct way is to introduce TJSHTMLFieldSet and declare the disabled
> property. As long as that class does not exist, see above.

Hello,

for the time being I defined a TJSHTMLFieldSet class but since it isn't 
complete (I just exposed the 'disabled' attribute) I won't submit a patch.

My new question is why the  T*Widget classes don't expose the underlying 
disabled attribute of the TJSHTMLElement that have it.

I suppose it's just lack of time.

Since the Element property is protected, I'm using an ugly class 
helper/class cracker combo (and using enabled rather than disabled 
because it's what normal lazarus controls have), see below.

A tangential question is, what should one use? T*Widgets or TJSHTMLElements?


---------------8<---------------8<---------------8<---------------8<--------


   TButtonEnabledHelper = class helper for TButtonWidget
   private
     function GetEnabled: boolean;
     procedure SetEnabled(AValue: boolean);
   public
     property enabled:boolean read GetEnabled write SetEnabled;
   end;


   TCrackButtonWidget = class(TButtonWidget)
   end;


function TButtonEnabledHelper.GetEnabled: boolean;
begin
  result:=not 
TJSHTMLButtonElement(TCrackButtonWidget(self).element).disabled;
end;

procedure TButtonEnabledHelper.SetEnabled(AValue: boolean);
begin
  TJSHTMLButtonElement(TCrackButtonWidget(self).Element).disabled:=not 
AValue;
end;


---------------8<---------------8<---------------8<---------------8<--------

Bye
-- 
Luca


More information about the Pas2js mailing list