arpo
How do I but a label on the button?
The code in HelloGUI looks like this but has no label.
// Create a Button
auto* button = new Button(context_);
button->SetName("Button");
button->SetMinHeight(24);
How do I but a label on the button?
The code in HelloGUI looks like this but has no label.
// Create a Button
auto* button = new Button(context_);
button->SetName("Button");
button->SetMinHeight(24);
Urho UI is a kind of toolkit with basic building blocks.
Button is responsible for clicking. Text is responsible for text. BorderImage is responsible for picture.
So, you have to put Text element into Button element if you want to have text. If you want to have button with picture, put BorderImage into Button instead.
See sample 17_SceneReplication/SceneReplication.cpp
Button* SceneReplication::CreateButton(const String& text, int width)
{
auto* cache = GetSubsystem<ResourceCache>();
auto* font = cache->GetResource<Font>("Fonts/Anonymous Pro.ttf");
auto* button = buttonContainer_->CreateChild<Button>();
button->SetStyleAuto();
button->SetFixedWidth(width);
auto* buttonText = button->CreateChild<Text>();
buttonText->SetFont(font, 12);
buttonText->SetAlignment(HA_CENTER, VA_CENTER);
buttonText->SetText(text);
return button;
}
buttonText->SetInternal(true);