setDefaultText doesnt seem to work on 1.0rc

Started by pmiloslavsky, 24 September 2023, 16:05:19

pmiloslavsky

QuoteeditBox = tgui::EditBox::create();
  editBox->setSize(100, 20);
  editBox->setTextSize(14);
  editBox->setPosition("parent.left + 1200", "parent.bottom - 300");
  editBox->setDefaultText("dec triple");
  pgui->add(editBox, "interior_color_adjust");
  editBox->onTextChange(signalIntColorAdj, p_model, pgui);
  editBox->setDefaultText("dec triple");

I don't see the text "dec triple" when the gui starts up. Do you have any idea why?
I don't do anything to the box, except hide all widgets sometimes.

texus

That code should work, and it works here. So something else must be happening to cause this.
- Is the text being rendered when you type something into the edit box?
- Does the text show if you call setText?
- Are you certain there isn't another edit box placed on top of it?

pmiloslavsky

Yes it works when I do setText, but its not ideal since i'm trying to get people to type a big decimal number in there and when they go to edit, they would be editing the dec triple string.
I think the fact that setText works eliminates all 3 theories above. I am using SFML 2.6 on windows

texus

Are you setting a custom theme?
The only difference between the default and normal text is that the default text can uses a different font, style and text color. So maybe the text color is transparent or the same color as the background color.

Can you try adding the following to check?
Code (cpp) Select
editBox->getRenderer()->setDefaultTextColor(tgui::Color::Black);

pmiloslavsky

Yes that was it, thank you again. I was using BabyBlue potentially from tgui 0.8

Quote// Theme based on http://dribbble.com/shots/635698-UI-Kit-Baby-Blue

Button {
    Texture      = "BabyBlue.png" Part(269, 40, 90, 60) Middle(30, 0, 30, 60);
    TextureHover = "BabyBlue.png" Part(361, 40, 90, 60) Middle(30, 0, 30, 60);
    TextureDown  = "BabyBlue.png" Part(177, 40, 90, 60) Middle(30, 0, 30, 60);
    TextColor    = rgb(100, 100, 100);
}


ChatBox {
    BackgroundColor = rgb(210, 210, 210);
    BorderColor     = White;
    Borders         = (2, 2, 2, 2);
    Scrollbar       = &Scrollbar;
}

CheckBox {
    TextureChecked   = "BabyBlue.png" Part(48, 40, 34, 36);
    TextureUnchecked = "BabyBlue.png" Part(381, 2, 31, 31);
    TextColor        = rgb(100, 100, 100);
}

ChildWindow {
    TextureTitleBar        = "BabyBlue.png" Part(317, 2, 62, 31) Middle(10, 0, 42, 31);
    TitleColor             = rgb(100, 100, 100);
    BackgroundColor        = rgb(230, 230, 230);
    BorderColor            = White;
    Borders                = (2, 0, 2, 2);
    DistanceToSide         = 3;
    PaddingBetweenButtons  = 1;
    ShowTextOnTitleButtons = false;

    CloseButton = {
        Texture      = "BabyBlue.png" Part(96, 2, 25, 25);
        TextureHover = "BabyBlue.png" Part(123, 2, 25, 25);
        TextureDown  = "BabyBlue.png" Part(150, 2, 25, 25);
    }

    MaximizeButton = {
        Texture      = "BabyBlue.png" Part(2, 90, 25, 25);
        TextureHover = "BabyBlue.png" Part(29, 90, 25, 25);
        TextureDown  = "BabyBlue.png" Part(56, 90, 25, 25);
    }

    MinimizeButton = {
        Texture      = "BabyBlue.png" Part(83, 90, 25, 25);
        TextureHover = "BabyBlue.png" Part(110, 90, 25, 25);
        TextureDown  = "BabyBlue.png" Part(137, 90, 25, 25);
    }
}

ComboBox {
    TextureArrow     = "BabyBlue.png" Part(177, 2, 20, 26);
    BackgroundColor  = rgb(210, 210, 210);
    TextColor        = rgb(100, 100, 100);
    BorderColor      = White;
    Borders          = (2, 2, 2, 2);
    ListBox          = &ListBox;
}

EditBox {
    Texture                     = "BabyBlue.png" Part(103, 40, 72, 48) Middle(24, 0, 24, 48);
    TextColor                   = rgb(100, 100, 100);
    SelectedTextColor           = rgb(150, 150, 150);
    SelectedTextBackgroundColor = rgb(190, 225, 235);
    CaretColor                  = rgb(145, 180, 190);
    Padding                     = (14, 4, 14, 4);
}

Label {
    TextColor = rgb(100, 100, 100);
    Scrollbar = &Scrollbar;
}

ListBox {
    BackgroundColor         = rgb(210, 210, 210);
    TextColor               = rgb(100, 100, 100);
    SelectedBackgroundColor = rgb(190, 225, 235);
    SelectedTextColor       = rgb(150, 150, 150);
    BorderColor             = White;
    Borders                 = (2, 2, 2, 2);
    Scrollbar               = &Scrollbar;
}

MenuBar {
    BackgroundColor         = rgb(210, 210, 210);
    TextColor               = rgb(100, 100, 100);
    SelectedBackgroundColor = rgb(190, 225, 235);
    SelectedTextColor       = rgb(150, 150, 150);
    DistanceToSide          = 5;
}

MessageBox {
    Button    = &Button;
    TextColor = rgb(100, 100, 100);

    TextureTitleBar = "BabyBlue.png" Part(317, 2, 62, 31) Middle(10, 0, 42, 31);
    TitleColor      = rgb(100, 100, 100);
    BackgroundColor = rgb(230, 230, 230);
    BorderColor     = White;
    Borders         = (2, 0, 2, 2);
    DistanceToSide  = 3;

    CloseButton = {
        Texture      = "BabyBlue.png" Part(96, 2, 25, 25);
        TextureHover = "BabyBlue.png" Part(123, 2, 25, 25);
        TextureDown  = "BabyBlue.png" Part(150, 2, 25, 25);
    }
}

Panel {
    BackgroundColor = rgb(230, 230, 230);
}

ProgressBar {
    TextureBackground  = "BabyBlue.png" Part(221, 2, 30, 30) Middle(10, 0, 10, 30);
    TextureFill        = "BabyBlue.png" Part(70, 2, 24, 24) Middle(7, 0, 7, 24);
    TextColor          = rgb(100, 100, 100);
}

RadioButton {
    TextureChecked   = "BabyBlue.png" Part(253, 2, 30, 30);
    TextureUnchecked = "BabyBlue.png" Part(285, 2, 30, 30);
    TextColor        = rgb(100, 100, 100);
}

Scrollbar {
    TextureTrack     = "BabyBlue.png" Part(432, 2, 16, 32);
    TextureThumb     = "BabyBlue.png" Part(414, 2, 16, 32);
    TextureArrowUp   = "BabyBlue.png" Part(2, 2, 16, 16);
    TextureArrowDown = "BabyBlue.png" Part(20, 2, 16, 16);
}

Slider {
    TextureTrack = "BabyBlue.png" Part(38, 2, 30, 20) Middle(10, 0, 10, 20);
    TextureThumb = "BabyBlue.png" Part(84, 40, 17, 38);
}

SpinButton {
    TextureArrowUp   = "BabyBlue.png" Part(2, 2, 16, 16);
    TextureArrowDown = "BabyBlue.png" Part(20, 2, 16, 16);
}

Tabs {
    TextureTab         = "BabyBlue.png" Part(450, 2, 44, 36) Middle(4, 3, 36, 30);
    TextureSelectedTab = "BabyBlue.png" Part(2, 40, 44, 36) Middle(4, 3, 36, 30);
    TextColor          = rgb(100, 100, 100);
    SelectedTextColor  = rgb(150, 150, 150);
    DistanceToSide     = 5;
}

TextBox {
    BackgroundColor             = rgb(210, 210, 210);
    TextColor                   = rgb(100, 100, 100);
    SelectedTextColor           = rgb(150, 150, 150);
    SelectedTextBackgroundColor = rgb(190, 225, 235);
    CaretColor                  = rgb(145, 180, 190);
    BorderColor                 = White;
    Borders                     = (2, 2, 2, 2);
    Scrollbar                   = &Scrollbar;
}

Tooltip {
    TextColor       = rgb(100, 100, 100);
    BackgroundColor = rgb(210, 210, 210);
    BorderColor     = rgb(255, 255, 255);
    Borders         = (1, 1, 1, 1);
    Padding         = (2, 2, 2, 2);
}


pmiloslavsky

#5
I replaced the cached themes directory with the 1.0 one, but I'm still not sure whats going wrong in BabyBlue:

  tgui::Theme theme;
  theme.load("..\\..\\..\\themes\\BabyBlue.txt");
  //tgui::Theme::setDefault("..\\..\\..\\themes\\BabyBlue.txt");
  tgui::Theme::setDefault(make_shared<tgui::Theme>(theme));

If I pass Black.txt here everything works so the theme has some bug?

texus

This is indeed a bug. If the theme doesn't specify the DefaultTextColor property (which BabyBlue doesn't), then the text is rendered with a transparent color (even though DefaultTextColor property is internally initialized with a grey color as default).

This has now been fixed in the latest version (github commit).