"term does not evaluate to a function taking X arguments"

Started by xxh, 24 May 2016, 23:46:36

xxh

QuoteWhat about just passing the edit boxes themselves as parameter like the original example code did?
That didn't seem to work for me... compiler error.

Quotecall "editBoxUsername = theme->load(...)"

Alright, I think I have it now. If I HAVE to do it this way...

private:
tgui::Gui _gui;
tgui::EditBox::Ptr _editBoxUsername;
tgui::EditBox::Ptr _editBoxPassword

...

_editBoxUsername = theme->load("EditBox");
_editBoxUsername->setSize(windowWidth * 2 / 3, windowHeight / 8);
_editBoxUsername->setPosition(windowWidth / 6, windowHeight / 6);
_editBoxUsername->setDefaultText("Username");
_editBoxUsername->setText("hello");
gui.add(_editBoxUsername, "Username");

_editBoxPassword = tgui::EditBox::copy(_editBoxUsername);
_editBoxPassword->setPosition(windowWidth / 6, windowHeight * 5 / 12);
_editBoxPassword->setPasswordCharacter('*');
_editBoxPassword->setDefaultText("Password");
_editBoxPassword->setText("testing");
gui.add(_editBoxPassword, "Password");

...

...
void ConnectionScreen::login()
{
_window.setTitle(_editBoxUsername->getText() + " : " + _editBoxPassword->getText()); //just to test
}
...

button->connect("pressed", &ConnectionScreen::login, this);


This is the only way I could get it to work so far.

But at least it's working.

Thanks a lot, again.

texus

QuoteThat didn't seem to work for me... compiler error.
Wasn't that compiler error just because you were missing a parameter to the connect function? Or are you talking about a different compile error?

xxh

Oh, you're right.

   button->connect("pressed", &ConnectionScreen::login, this, editBoxUsername, editBoxPassword);

It does work after all.
Cool, that's better and more convenient.

texus

Just to give you yet another option: you can use gui.get to retrieve these edit boxes so that you don't have to store them anywhere in your code. The login function only needs access to gui and then you can do this:
Code (cpp) Select
_window.setTitle(_gui.get<tgui::EditBox>("Username")->getText() + " : " + _gui.get<tgui::EditBox>("Password")->getText());

In this case the login function was part of the class that contains the gui so you could access it directly, but in case it would be a free function or part of a different class you can solve it by passing the gui as reference parameter:
Code (cpp) Select
void ConnectionScreen::login(tgui::Gui& gui);
button->connect("pressed", &ConnectionScreen::login, &screen, std::ref(gui));


But in this case just passing the edit boxes directly is probably the most convenient way.

xxh

_window.setTitle(_gui.get<tgui::EditBox>("Username")->getText() + " : " + _gui.get<tgui::EditBox>("Password")->getText());

it identifies them from gui.add(editBoxUsername, "Username"); this right?
that's nice to know, might need that for other things!

Very good information. You're so helpful :)
Definitely looking forward to exploring and learning more about this awesome library.

By the way, does the RichTextLabel support vertical scrollbar? It would be really cool to use that as a chat box or similar.

texus

Quoteit identifies them from gui.add(editBoxUsername, "Username"); this right?
Yep

Quotedoes the RichTextLabel support vertical scrollbar?
No, it is just a wrapper around some class that was written for sfml. The RichTextLabel would have to be completely rewritten to be really useful.

QuoteIt would be really cool to use that as a chat box or similar
You could also check out the ChatBox class for that :). That class does have a scrollbar.