Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - cpyro

Pages: [1]
Help requests / Re: Undefined reference to .connect
« on: 19 June 2020, 13:36:35 »
I was not including TGUI.hpp! I only had "#include <TGUI/Widgets/EditBox.hpp>". Now it works, thank you!

Help requests / Undefined reference to .connect
« on: 19 June 2020, 10:43:17 »
Hi, I've been trying to get .connect working, but am having trouble. Partial code below. For more context, the Screen class is a thin wrapper around tgui::Gui, and has methods render() and checkForEvent(). The Controller class is intended to construct Screens.

    void StartScreenController::constructJoinScreen() {
        auto gui = std::make_shared<tgui::Gui>(*this->_window);

        int win_x = this->_window->getSize().x;
        int win_y = this->_window->getSize().y;

        // Edit boxes
        auto editBox = tgui::EditBox::create();
        editBox->setSize(200, 25);
        editBox->setPosition(win_x/2-300, win_y/2);
        editBox->setDefaultText("Enter host IP address...");

        // This line of code below causes an error when uncommented.
        // editBox->connect("ReturnKeyPressed", &StartScreenController::handleEnterHostIpAddress, this);


        this->_join_screen = ss::Screen(this->_window, gui, "../resources/images/main_bg.png");

    void StartScreenController::handleEnterHostIpAddress(const sf::String& buttonText) {
        std::cout << "enter host ip game" << std::endl;

This works (edit box appears and you can type in it) when the problematic line of code commented out. When the line is uncommented, I get this error:

undefined reference to `unsigned int tgui::SignalWidgetBase::connect<void (ss::StartScreenController::*)(sf::String const&), ss::StartScreenController*>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void (ss::StartScreenController::*&&)(sf::String const&), ss::StartScreenController* const&)'

I don't understand why I get this error; any ideas? I wonder if I have to cast my classes into something more appropriate, but haven't seen that in other examples I've seen online...

Pages: [1]