Lahrach Hakim Posted March 12, 2014 Posted March 12, 2014 Hi, I try to learn fast how create unigui web component , so I have get from samples -control1- and I try to add property like changing color button. The component that I have modified can not change color, I don't know why I have try to attach the modified code but there is error when uploading file (Error You aren't permitted to upload this kind of file) Can you help me please. This is the code below : //------------------------------------------------------------------------------------------------------------------- unit UniCustomControl1; interface uses SysUtils, Classes, Controls, uniGUIBaseClasses, uniGUIClasses, extctrls,Graphics; type // TUniControl is base for all visual controls // TuniControl is not a container and can not be a parent for other TUniControls TUniMyButton = class(TUniControl) private { Private declarations } FHrefTarget : string; FHref : string; FPressed : Boolean; fLedColor : TColor; fIsLedOn : boolean; protected function GetLedColor : TColor; procedure SetLedColor (LedColor : TColor); procedure ConfigJSClasses(ALoading: Boolean); override; function VCLControlClassName: string; override; function GetHref: string; procedure SetHref(const Value: string); procedure InternalSetCaption(Value: string); override; function GetHrefTarget: string; procedure SetHrefTarget(const Value: string); procedure WebCreate; override; procedure LoadCompleted; override; public constructor Create(AOwner: TComponent); override; published property Href: string read GetHref write SetHref; property HrefTarget: string read GetHrefTarget write SetHrefTarget; property Pressed: Boolean read FPressed write FPressed default False; property LedColor : TColor read GetLedColor write SetLedColor; property Caption; property RTL; end; procedure Register; implementation procedure TUniMyButton.SetLedColor (LedColor : TColor); begin if FLedColor<>LedColor then begin FLedColor:=LedColor; JSProperty('LedColor', [fLedColor], 'SetLedColor'); end; end; function TUniMyButton.GetLedColor : TColor; begin Result := fLedColor; end; procedure TUniMyButton.ConfigJSClasses(ALoading: Boolean); begin JSObjects.DefaultJSClassName:='Ext.button.Button'; end; function TUniMyButton.VCLControlClassName: string; begin Result:=''; end; constructor TUniMyButton.Create(AOwner: TComponent); begin inherited; Width:=85; Height:=25; FHrefTarget := '_blank'; end; procedure TUniMyButton.WebCreate; begin inherited; JSConfig('border', [5]); JSConfig('LedColor', [GetLedColor]); end; procedure TUniMyButton.LoadCompleted; begin inherited; JSConfig('pressed', [FPressed]); end; function TUniMyButton.GetHref: string; begin Result:=FHref; end; procedure TUniMyButton.SetHref(const Value: string); begin if FHref<>Value then begin FHref:=Value; JSProperty('href', [FHref], 'setHref'); end; end; function TUniMyButton.GetHrefTarget: string; begin Result:=FHrefTarget; end; procedure TUniMyButton.SetHrefTarget(const Value: string); begin if FHrefTarget<>Value then begin FHrefTarget:=Value; JSProperty('hrefTarget', [FHrefTarget]); end; end; procedure TUniMyButton.InternalSetCaption(Value: string); begin inherited; JSProperty('text', [Value], 'setText'); end; procedure Register; begin RegisterComponents('uniSamples', [TUniMyButton]); end; end. //------------------------------------------------------------------------------------------------------------------- Thank you Quote
Administrators Farshad Mohajeri Posted March 12, 2014 Administrators Posted March 12, 2014 JSProperty('LedColor', [fLedColor], 'SetLedColor'); What is LedColor? Only properties and methods from Ext JS can be used here: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.button.Button Quote
Lahrach Hakim Posted March 13, 2014 Author Posted March 13, 2014 HI Mohajeri, Thank you for your express reply. I have make serach in http://docs.sencha.c...t.button.Button and no propertie color is nassifned to button. So what doing. Thank you. Quote
Administrators Farshad Mohajeri Posted March 13, 2014 Administrators Posted March 13, 2014 Ext JS buttons are drawn with CSS and background images. You can not change button color without changing the CSS and associated images. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.