jahlxx Posted May 9, 2016 Posted May 9, 2016 Hi. How can I change the color of a uniedit con focus and on lost focus? In vcl app, I rewrite in run time the onenter and onexit procedure, but not in every edit component, I have a procedure that rewrites these pocedures on the edt's when the form is created or showed. Quote
Sherzod Posted May 9, 2016 Posted May 9, 2016 Hi, Can you try this ?: procedure TMainForm.UniEdit1Enter(Sender: TObject); begin UniEdit1.Color := clLime end; procedure TMainForm.UniEdit1Exit(Sender: TObject); begin UniEdit1.Color := clWhite end; Best regards Quote
bugra Posted May 9, 2016 Posted May 9, 2016 Hi First change uniEdit's color property. Then in ClientEvent find mouseover event and add this for focus function mouseover(sender, eOpts) { document.getElementById(sender.getInputId( )).style.backgroundColor = "lightblue"; document.getElementById(sender.getInputId( )).style.color = "#FF0000"; } and add this for lost focus function mouseout(sender, eOpts) { document.getElementById(sender.getInputId( )).style.backgroundColor = "#ffffff"; document.getElementById(sender.getInputId( )).style.color = "#000000"; } Quote
jahlxx Posted May 9, 2016 Author Posted May 9, 2016 ok, but with these two solutions, I must to write the events for every uniedit. In vcl applications, I have only one procedure that rewrite these events in runtime, for every edit in the application, without write the events for every edit. Thanks. Quote
bugra Posted May 11, 2016 Posted May 11, 2016 Try this procedure TMainForm.UniFormCreate(Sender: TObject); var i:Integer; begin for i := ComponentCount - 1 downto 0 do begin if Components[i] is TUniEdit then begin (Components[i] as TUniEdit).Color := clWhite; (Components[i] as TUniEdit).ClientEvents.ExtEvents.Values['mouseout']:='function mouseout(sender, eOpts)'+ '{ document.getElementById(sender.getInputId( )).style.backgroundColor = "#ffffff";'+ ' document.getElementById(sender.getInputId( )).style.color = "#000000";}'; (Components[i] as TUniEdit).ClientEvents.ExtEvents.Values['mouseover']:='function mouseout(sender, eOpts)'+ '{ document.getElementById(sender.getInputId( )).style.backgroundColor = "lightblue";'+ ' document.getElementById(sender.getInputId( )).style.color = "#FF0000";}'; end; end; end; 1 Quote
jahlxx Posted May 12, 2016 Author Posted May 12, 2016 ok. it partially works. I use your code, but instead of "mouseover", I use "focus", and works. But I can't find mand event for when lost focus. Quote
Sherzod Posted May 12, 2016 Posted May 12, 2016 ok. it partially works. I use your code, but instead of "mouseover", I use "focus", and works. But I can't find mand event for when lost focus. Hi, You can use "blur" event Best regards. 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.