Jump to content

Change css style after creating a uniButton


innocon
 Share

Recommended Posts

Hi, 
 
I created a unibutton on the fly, this works fine. BUT: I like to change the style by using css with ClientEvents.ExtEvents.Add, this doesn't seem to show any difference. The button inherits the settings from x-btn instead  :(
 
Any clues?
 
ps: applying ClientEvents.ExtEvents.Add to unibutton which is created at design time does work!

 

 

 
procedure TMainFormV2.UniFormShow(Sender: TObject);
var st:string;
      nwbtn:TUniButton;
Begin
 
    st:='OnBeforerender=function OnBeforerender(sender) '+
    ' {'+
    'sender.cls="btngray";'+
    'sender.overCls="btngray-over";'+
    'sender.textAlign=''left'';'+
    '}';
 
    nwbtn:=TUniButton.Create(MainFormV2);
    nwbtn.Parent:=MainFormV2;
    nwbtn.Top:=10;
    nwbtn.left:=15;
    nwbtn.Width:=170;
    nwbtn.Height:=20;
    nwbtn.Caption:='Press here';
    nwbtn.Cursor:=crHandPoint;
    nwbtn.OnClick:=SelectionClick;
 
    nwbtn.ClientEvents.ExtEvents.Add(st);
 

end;

Link to comment
Share on other sites

Hi JRV.
 
Solution for "left" ...
uses ... UniGUIApplication ...
UniSession.AddJS('document.getElementById("'+nwbtn.JSName+'_id-btnEl").className = "x-btn-left";');

  

    nwbtn:=TUniButton.Create(MainFormV2);
    nwbtn.Parent:=MainFormV2;
    nwbtn.Top:=10;
    nwbtn.left:=15;
    nwbtn.Width:=170;
    nwbtn.Height:=20;
    nwbtn.Caption:='Press here';
    nwbtn.Cursor:=crHandPoint;
    nwbtn.OnClick:=SelectionClick;
    UniSession.AddJS('document.getElementById("'+nwbtn.JSName+'_id-btnEl").className = "x-btn-left";');
 
Sincerely.
  • Upvote 1
Link to comment
Share on other sites

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...