Jump to content

Changing font, color, etc. of UnimSegmentedButton


likemike

Recommended Posts

Hello!

I've tested some things to change color etc. of the buttons in TUnimSegmentedButton. This is my result:

 

JSInterface.JSAddListener('painted',JSControl.JSFunction('me', 'me.element.select(".x-body-el").elements.forEach(function(el){el.style["font-size"] = "24px"});'));
JSInterface.JSAddListener('painted',JSControl.JSFunction('me', 'me.element.select(".x-body-el").elements.forEach(function(el){el.style["font-weight"] = "bold"});'));
JSInterface.JSAddListener('painted',JSControl.JSFunction('me', 'me.element.select(".x-body-el").elements.forEach(function(el){el.style["line-height"] = "24px"});')); // necessary! Otherwise the text is cut off 
JSInterface.JSAddListener('painted',JSControl.JSFunction('me', 'me.element.select(".x-inner-el").elements.forEach(function(el){el.style["background-color"] = "red"});'));
JSInterface.JSAddListener('painted',JSControl.JSFunction('me', 'me.element.select(".x-pressing").elements.forEach(function(el){el.style["background-color"] = "blue"});'));


Unfortunately I didn't found, how to change the select-background color (the color of the button, which is actually set to "pressed").

Any help is appreciated!

Regards

Mike

Link to comment
Share on other sites

  • 2 weeks later...
7 hours ago, Hayri ASLAN said:

Hello

Which theme are you using?

Hello!

The theme is "triton" (TouchTheme) and "classic" (Theme).

I looked here 

Quote

...\FMSoft\Framework\uniGUI\ext-7.0.0\build\classic\theme-triton\resources\theme-triton-all_1.css

and search for "SegmentedButton", but what I found didn't help me anyway.

If you find a solution, please tell me and perhaps you can describe, how to find those issues in the future.

Thanks

Link to comment
Share on other sites

2 hours ago, likemike said:

Hello!

The theme is "triton" (TouchTheme) and "classic" (Theme).

I looked here 

and search for "SegmentedButton", but what I found didn't help me anyway.

If you find a solution, please tell me and perhaps you can describe, how to find those issues in the future.

Thanks

Hello, Please use below solution.

Form-> OnCreate


procedure TMainmForm.UnimFormCreate(Sender: TObject);
begin
  with UnimSegmentedButton1, JSInterface do
    JSAddListener('painted', JSFunction('a', 'a.getPressedButtons()[0].innerElement.dom.style.backgroundColor= "#00AA00";'));
end;

UnimSegmentedButton -> ClientEvents -> ExtEvents -> toggle

function toggle(sender, button, isPressed, eOpts)
{
  if (isPressed){
    button.innerElement.dom.style.backgroundColor= '#00AA00';  
  }
  else{
    button.innerElement.dom.style.backgroundColor= ''; 
  }
}

 

Link to comment
Share on other sites

×
×
  • Create New...