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->setTextSize(18);
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);
gui->add(editBox);
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...