*

xxh

  • *
  • 11
    • View Profile
Re: "term does not evaluate to a function taking X arguments"
« Reply #15 on: 25 May 2016, 02:21:10 »
Quote
What 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.

Quote
call "editBoxUsername = theme->load(...)"

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

Code: [Select]
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

  • *****
  • 1342
    • View Profile
    • Texus's Blog
Re: "term does not evaluate to a function taking X arguments"
« Reply #16 on: 25 May 2016, 02:23:23 »
Quote
That 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

  • *
  • 11
    • View Profile
Re: "term does not evaluate to a function taking X arguments"
« Reply #17 on: 25 May 2016, 02:31:06 »
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

  • *****
  • 1342
    • View Profile
    • Texus's Blog
Re: "term does not evaluate to a function taking X arguments"
« Reply #18 on: 25 May 2016, 02:36:25 »
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:
_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:
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

  • *
  • 11
    • View Profile
Re: "term does not evaluate to a function taking X arguments"
« Reply #19 on: 25 May 2016, 02:43:11 »
_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

  • *****
  • 1342
    • View Profile
    • Texus's Blog
Re: "term does not evaluate to a function taking X arguments"
« Reply #20 on: 25 May 2016, 02:47:31 »
Quote
it identifies them from gui.add(editBoxUsername, "Username"); this right?
Yep

Quote
does 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.

Quote
It 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.