Пример #1
0
    TGUI_API Widget::Ptr loadButton(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr)
    {
        Button::Ptr button;
        if (widget)
            button = std::static_pointer_cast<Button>(widget);
        else
            button = std::make_shared<Button>();

        loadWidget(node, button);
        if (node->propertyValuePairs["text"])
            button->setText(DESERIALIZE_STRING("text"));
        if (node->propertyValuePairs["textsize"])
            button->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value));

        return button;
    }
Пример #2
0
    void MessageBox::addButton(const sf::String& caption)
    {
        Button::Ptr button;
        if (!getTheme() || m_buttonClassName.empty())
            button = std::make_shared<Button>();
        else
            button = getTheme()->internalLoad(getPrimaryLoadingParameter(), m_buttonClassName);

        button->setTextSize(m_textSize);
        button->setText(caption);
        button->connect("Pressed", [=](){ m_callback.text = caption; sendSignal("ButtonPressed", caption); });

        add(button, "#TGUI_INTERNAL$MessageBoxButton$" + caption + "#");
        m_buttons.push_back(button);

        rearrange();
    }