Jump to content

tUnipanel How to change color via ClientEvents


Luis Devis

Recommended Posts

Hi, thanks for your interest in my topic.

I need to use a tUnipanel that changes its color when it is pressed (mousedown) and go back to its original back color when the mouse/finger releases (mouseup).
I don't want to use Delphi code because it is too slow, I'd rather use  ClientEvents but I'm not yet used to them. Can you lend me a hand?

Thanks a lot for your help

Link to comment
Share on other sites

41 minutes ago, Luis Devis said:

the user should know that the panel has been pressed, otherwise they keep pressing and pressing and touching and breaking the screen 

Well, actually a panel is a container. It contains elements for interaction with the user.

Link to comment
Share on other sites

6 hours ago, Luis Devis said:

So, according to the answers, I gess that there is no way to do what I've asked.

Yes, it is possible to track panel clicks...

6 hours ago, Luis Devis said:

Hopw can I change the backGroudcolor of a tUnibutton when it is pressed and released using ClientEvents

Please clarify the question again. Since the UniButton has no state - pressed.

Link to comment
Share on other sites

OK, no matter what kind of UNIGUI control I will use.

I need a control that changes its colour (backcolor) when the event mouseon happens and returns to its original value when mouseup event happens.
And... I want to do it via ClientEvents, if possible, not using the Delphi classic events. The idea is to improve navigators response speed.

Link to comment
Share on other sites

On 7/5/2021 at 8:48 PM, Luis Devis said:

I need to use a tUnipanel that changes its color when it is pressed (mousedown) and go back to its original back color when the mouse/finger releases (mouseup).
I don't want to use Delphi code because it is too slow, I'd rather use  ClientEvents but I'm not yet used to them. Can you lend me a hand?

Okay. Try this approach.

1. 

Uses ... , UniGUIJSUtils;

2. 

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniPanel1 do
    JSInterface.JSAssign('originalBGColor', [uniColor2Web(Color)]);
end;

3. UniPanel1 -> ClientEvents -> ExtEvents ->

function mousedown(sender, x, y, eOpts)
{
    sender.setBodyStyle('background-color', 'green');
}

function mouseup(sender, x, y, eOpts)
{
    sender.setBodyStyle('background-color', sender.originalBGColor);
}

 

Link to comment
Share on other sites

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...