Close button

  • 6 Replies
  • 44 Views
Close button
« on: 06 October 2019, 17:18:03 »
I don't know how to modify the close button of a ChildWindow, cam someone help me?

Re: Close button
« Reply #1 on: 06 October 2019, 18:06:01 »
How exactly do you want modify it?

Re: Close button
« Reply #2 on: 06 October 2019, 18:07:56 »
Change the colors or set a texture

Re: Close button
« Reply #3 on: 06 October 2019, 18:27:46 »
Not sure about texture, but here code for changing color(from tests):

Code: [Select]
            tgui::ButtonRenderer closeButtonRenderer;
            closeButtonRenderer.setBackgroundColor(sf::Color::Red);
            ...
            ptr->getRenderer()->setCloseButton(closeButtonRenderer.getData());//ptr is pointer to your child window

Re: Close button
« Reply #4 on: 06 October 2019, 19:09:48 »
Now i try to use themes but when I read them my program crashes with:
terminate called after throwing an instance of 'tgui::Exception'
  what():  Error while parsing input at line 19. Found '=' while trying to read a value.
and the theme file is:
Button {
    BackgroundColor = rgb(47, 52, 63);
    BackgroundColorHover = rgb(67, 72, 83);
    TextColor = rgb(187, 196, 202);
    TextColorHover = rgb(187, 196, 202);
    BorderColor = rgb(0, 0, 0);
}

ChildWindow {
    TitleColor = rgb(187, 196, 202);
    TitleBarColor = rgb(47, 52, 63);
    BackgroundColor = rgb(51, 51, 51);
    BorderColor = rgb(0, 0, 0);
    DistanceToSide = 3;
    PaddingBetweenButtons = 1;
    ShowTextOnTitleButtons = true
    CloseButton = &Button;
    MaximizeButton = &Button;
    MinimizeButton = &Button;
}

Re: Close button
« Reply #5 on: 06 October 2019, 23:21:15 »
I've never used own themes so I've no idea why your code crashed, but in standard theme them defined separately. What if you also do so?
In any case better provide sample for reproducing the behavior.

*

texus

  • *****
  • 1475
    • View Profile
    • Texus's Blog
Re: Close button
« Reply #6 on: 07 October 2019, 11:09:57 »
It gives the exception because you are missing a semi-colon behind "ShowTextOnTitleButtons = true".
The parser sees "true CloseButton=&Button" as the value of ShowTextOnTitleButtons, which it considers invalid since it contains an unquoted '=' sign.