Jump to content

Recommended Posts

Posted

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.

 

Posted

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

Posted

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";
}
Posted

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.

Posted

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;
  • Upvote 1
Posted

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.

Posted

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.

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.

×
×
  • Create New...