Main Menu
Menu

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.

Show posts Menu

Messages - xxh

#1
_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.
#2
Oh, you're right.

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

It does work after all.
Cool, that's better and more convenient.
#3
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.
#4
Haha. As I was looking through all the code and copying it for you, I found the problem. I was using an else statement for textEntered because I have a separate input manager, and it was the only event not being passed to the screens.
My bad.  :P

Now if I could just find a way to pass the current text.
It seems I might have to put the editboxes in my class like
private:
tgui::EditBox::Ptr editBoxUsername;
then getText in the login function.
but would this work?
how will I set the theme (after), is that a problem?
#5
QuoteYou are right, it is perfectly valid code, it just doesn't do what you might expect.
If you pass "editBoxUsername->getText()" then the compiler will call that getText fuction (before calling your connect function) and store this string

That explains my edit about the text not changing. Damn, so I still don't have a solution.

QuoteCould you show the full code so that I can just copy-paste and try it here?
I'll have to mock up something similar that's simpler/smaller. Give me a bit.
#6
Well, I couldn't get either of those things to compile. I tried a few other things too.

I went back to trying    button->connect("pressed", &ConnectionScreen::login, this, editBoxUsername->getText(), editBoxPassword->getText()); and it actually works fine!

However, I have an unrelated problem. I'm not getting keyboard input in the EditBoxes. I can do ->setText() and it changes. I checked that the events are being pushed through
very strange..

I basically have
class ConnectionScreen : public g2c::GameScreen
{
...
private:
tgui::Gui _gui;
};

...

ConnectionScreen::ConnectionScreen(sf::RenderWindow& window) : GameScreen(window)
{
//ctor
_gui.setWindow(window);
}

(load content) -> loadWidgets(_gui);

void ConnectionScreen::updateEvent(sf::Event event)
{
.............
_gui.handleEvent(event);
.....
}


And the rest is the login example.

The typing/blinking cursor shows up when I click the boxes. But no keys input text to the boxes.  :o

EDIT: Backspace works, but nothing else does. Also if I backspace the text I used with setText, I still get the old text to the login function...
#7
Nice. The first one works.

However, the second with the std::binds gives me:
Quoteerror C3848: expression having type 'const std::_Bind<true,sf::String,std::_Pmf_wrap<sf::String (__thiscall tgui::EditBox::* )(void) const,sf::String,tgui::EditBox,>,tgui::EditBox::Ptr &>' would lose some const-volatile qualifiers in order to call 'sf::String std::_Bind<true,sf::String,std::_Pmf_wrap<sf::String (__thiscall tgui::EditBox::* )(void) const,sf::String,tgui::EditBox,>,tgui::EditBox::Ptr &>::operator ()<>(void)'   e:\dev\coding\lib\tgui-0.7\include\tgui\signal.hpp   191   1   GameTwo.Client

Really appreciate your (fast) help with this by the way. Thanks so much.
#8
Yes, with the two "test" strings I get that error.
Error   2   error C2064: term does not evaluate to a function taking 2 arguments   c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional   1149   1   GameTwo.Client

Quote1>------ Build started: Project: GameTwo.Client, Configuration: Debug Win32 ------
2>------ Build started: Project: GameTwo.Common, Configuration: Debug Win32 ------
2>  GameTwo.Common.vcxproj -> E:\Dev\Coding\Projects\GameTwo\GameTwo\Debug\GameTwo.Common.lib
1>  ConnectionScreen.cpp
1>e:\dev\coding\projects\gametwo\gametwo\src\connectionscreen.cpp(52): warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1149): error C2064: term does not evaluate to a function taking 2 arguments
1>          class does not define an 'operator()' or a user defined conversion operator to a pointer-to-function or reference-to-function that takes appropriate number of arguments
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1137) : see reference to function template instantiation 'void std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>::_Do_call<,0,1>(std::tuple<>,std::_Arg_idx<0,1>)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1137) : see reference to function template instantiation 'void std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>::_Do_call<,0,1>(std::tuple<>,std::_Arg_idx<0,1>)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\xrefwrap(283) : see reference to function template instantiation 'void std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>::operator ()<>(void)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\xrefwrap(283) : see reference to function template instantiation 'void std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>::operator ()<>(void)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<std::_Bind<true,_Ret,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>,false>::_ApplyX<_Rx,>(void)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Rx=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<std::_Bind<true,_Ret,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>,false>::_ApplyX<_Rx,>(void)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Rx=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(226) : while compiling class template member function 'void std::_Func_impl<_MyWrapper,_Alloc,_Ret,>::_Do_call(void)'
1>          with
1>          [
1>              _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Ret=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(495) : see reference to class template instantiation 'std::_Func_impl<_MyWrapper,_Alloc,_Ret,>' being compiled
1>          with
1>          [
1>              _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Ret=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>  ,            _Fty=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>          ]
1>          e:\dev\coding\lib\tgui-0.7\include\tgui\signal.hpp(153) : see reference to function template instantiation 'std::function<void (void)>::function<std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fx=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>          ]
1>          e:\dev\coding\lib\tgui-0.7\include\tgui\signal.hpp(153) : see reference to function template instantiation 'std::function<void (void)>::function<std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fx=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string),void,g2c::ConnectionScreen,std::string,std::string>,const char *&,const char *&>
1>          ]
1>          e:\dev\coding\lib\tgui-0.7\include\tgui\signal.hpp(152) : while compiling class template member function 'std::function<void (void)> tgui::priv::connector<type,Func,const char *,const char *>::connect(Func,size_t,const char *,const char *)'
1>          with
1>          [
1>              Func=void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string)
1>          ]
1>          e:\dev\coding\lib\tgui-0.7\include\tgui\signal.hpp(240) : see reference to function template instantiation 'std::function<void (void)> tgui::priv::connector<type,Func,const char *,const char *>::connect(Func,size_t,const char *,const char *)' being compiled
1>          with
1>          [
1>              Func=void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string)
1>          ]
1>          e:\dev\coding\lib\tgui-0.7\include\tgui\signal.hpp(240) : see reference to class template instantiation 'tgui::priv::connector<type,Func,const char *,const char *>' being compiled
1>          with
1>          [
1>              Func=void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string)
1>          ]
1>          e:\dev\coding\lib\tgui-0.7\include\tgui\signal.hpp(354) : see reference to function template instantiation 'void tgui::Signal::connect<Func,const char*,const char*>(unsigned int,Func,const char *,const char *)' being compiled
1>          with
1>          [
1>              Func=void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string)
1>          ]
1>          e:\dev\coding\projects\gametwo\gametwo\src\connectionscreen.cpp(146) : see reference to function template instantiation 'unsigned int tgui::SignalWidgetBase::connect<void(__thiscall g2c::ConnectionScreen::* )(std::string,std::string),const char*,const char*>(const std::string &,Func,const char *,const char *)' being compiled
1>          with
1>          [
1>              Func=void (__thiscall g2c::ConnectionScreen::* )(std::string,std::string)
1>          ]
========== Build: 1 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
#9
Okay, I tried changing it up a bit.

void ConnectionScreen::login(std::string username, std::string password)

button->connect("pressed", &ConnectionScreen::login, "test", "test"); //passing it manually

button->connect("pressed", &ConnectionScreen::login, editBoxUsername->getText(), editBoxPassword->getText()); //testing if I can get the text from the editbox directly instead of passing the editbox


but these both give me the same error...

Am I doing it wrong?
#10
Alright, thank you for the info. And sorry I didn't see the other person inquiring about it.

I've looked through the examples a bit, but I can't seem to find a way to get events (e.g. button clicks) from the GUI without ->connect (which doesn't work)
Is there another method to call functions when a GUI component is clicked? Or a workaround of some kind?
Maybe I'm missing something here...

Would appreciate your help.
#11
- What compiler version are you using? Visual Studio 2013 update 5
- Did you download the precompiled libraries, or did you build from source? precompiled
- Are you linking statically, or dynamically? statically
- If needed/possible, provide a complete but minimal example that I can test.

I've tried modifying and using multiple examples, tutorials on the site into a class. But every time I try to do a signal ->connect
e.g.     button->connect("pressed", &MyClass::login, editBoxUsername, editBoxPassword);
or even removing the parameters (button->connect("pressed", &MyClass::login)
I get the error
Error   2   error C2064: term does not evaluate to a function taking 2 arguments   c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional   1149   1   
or 0 arguments... any arguments. It doesn't seem to like the binding, and I have no idea how to fix this.