[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Change the color after click  XML
Forum Index -> Development
Author Message
gseijo

Active

Joined: 29/09/2020 14:14:26
Messages: 21
Offline

Is there a "@backgroundModiFier ..." command so that I can change the color of the button I clicked?

Something like "@backgroundModifierPressed@"?

Thnxx
Gori
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5535
Offline

Hi Gori,

there is one - it is called "backgroundModifiertActive".

You can assign to each component individual by using risc value "_backgroundModifierActive". Or you can change the global variable "@backgroundModifiertActive@".

By default it is a light orange shading that is applied on top of the e.g. button
("linear-gradient(to bottom, rgba(255,128,0,0.1),rgba(255,128,0,0.1))").

Please always work with gradients when working with background modifiers, even when the color is for the from and the to-value.

Regards, Björn

Björn Müller, CaptainCasa GmbH
gseijo

Active

Joined: 29/09/2020 14:14:26
Messages: 21
Offline

Hi Björn,

"_backgroundModifierActive" or "_backgroundModifiertActive".?

But, don't workz.
The button only changes the color when i click on it, when i let go it takes the standard color.

what's wrong?
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5535
Offline

Hi Gori,

uuuh - you are the first to find this typo...

The "RISC-value" that is referenced in the style class is "_backgroundModifierActive" (no t) - the default style variable is "@backgroundModifiertActive@" (with t).

Due to compatibility we cannot update this, because the variable already might be overridden for custom styles.

OK, I though you only want to change for the clicking-phase. But you want the button to change its color, to indicate it was pressed.

You have to simply do so by using the normal BACKGROUND attribute of the button, and bind it to some expression value:

Code:
 ...
    <t:button id=... 
         text=... 
         background="#{d.YourUI.xyzButtonBackground}" 
         actionListener="#{d.YourUI.onXyzButtonAction}"/>
 ...
 


...and then in the program define somehing like

Code:
 boolean m_buttonPressed=false;
 
 public void onXyzButtonAction(ActionEvent ...)
 {
     m_buttonPressed = true;
 }
 public String getXyzButtonBackground()
 {
     if (m_buttonPressed == true)
         return "#FF000030"; // some red overlaying...
     else
         return null; // no special coloring
 }
 


Of course: you can update the background in many ways...

...the BACKGROUND attribute
...the BGPAINT attribute
...the STYLESEQ attribute (pointing to a style class)
...the STYLEVARIANT attribute

So using the BACKGROUND in the example is only one possibility.

I hope I did not add to many typos in the code above...

Regards, Björn

Björn Müller, CaptainCasa GmbH
gseijo

Active

Joined: 29/09/2020 14:14:26
Messages: 21
Offline

thnxx Björn
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team