Here is what I get:
Set the text using a std::string, which is converted to an internal TextString.
I think I should find out the secret of TextString.
Oceane wrote:
> Forgive my silly typo, I did mean std::string.
>
> It is strange that now
>
> std::string str = "This is the first line \n This is
> the second line";
> text->setText(str);
> works!!!
>
> I don't know why it failed two hours ago.
>
> But if I change the str content with things read from external files, the \n
> does not work again'(
>
> When creating the external text files, I already added the breaker into the
> contents.
>
> Thanks anyway!!!
>
>
>
>
> Wojtek wrote:
> > Hi,
> >
> > Hmm, still have doubts. Because of uppercase String name yu just wrote.
> > std::String does not exist. I would be ok, though, if you wrote you did
> > declare it as std::string (lowercase) ;-). But lets assume you did just
> > that and it still does not work, so then I would suggest to enter setText
> > call with debugger and see what version of it is called. Is it setText(
> > const osgText::String & ) or setText( const std::string & ) or
> > setText(const wchar_t* text) ? See which one is this and then select proper
> > type as your type for declaring str variable.
> >
> >
> > Cheers,
> > Wojtek
> >
> >
> >
> > 2013/9/5 Fan ZHANG < ()>
> >
> > > Thanks for your reply.
> > >
> > > In my codes, I did declare it as std::String str.
> > >
> > > Just simply put String here to illustrate:)
> > >
> > >
> > > Wojtek wrote:
> > >
> > > > Hi,
> > > >
> > > >
> > > > Its just a guess, but I believe your call: text->setText("This is the
> > > > first line n This is the second line");
> > > > is done implicit conversion to std::string and calling following method:
> > > > TextBase::setText( const std::string & );
> > > >
> > > > so in your code I would try declaring str variable as std::string (not
> > > > a String as you did).
> > > >
> > > >
> > > > Cheers,
> > > > Wojtek Lewandowski
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > > 2013/9/5 Fan ZHANG < ()>
> > > >
> > > >
> > > > > Thanks for your reply but it still does not work:(
> > > > >
> > > > >
> > > > >
> > > > > Sebastian Messerschmidt wrote:
> > > > >
> > > > >
> > > > > > Hi Fan,
> > > > > >
> > > > > > Could you try:
> > > > > >
> > > > > > String str = "This is the first line n This is the second line";
> > > > > > text->setText(str);
> > > > > >
> > > > > > (note the double )
> > > > > >
> > > > > > cheers
> > > > > > Sebastian
> > > > > >
> > > > > >
> > > > > >
> > > > > > > Hi all,
> > > > > > >
> > > > > > > Sorry to disturb but I have a question about the line breaker 'n'.
> > > > > > >
> > > > > > > If I use text->setText("This is the first line n This is the
> > > > > > > second line");
> > > > > > >
> > > > > > > It works and gets the result as:
> > > > > > >
> > > > > > > This is the first line
> > > > > > > This is the second line
> > > > > > >
> > > > > > > But if I read the string from a variable, it does not work,
> > > > > > > namely,
> > > > > > >
> > > > > > > String str = "This is the first line n This is the second line";
> > > > > > > text->setText(str);
> > > > > > >
> > > > > > > The result will be:
> > > > > > >
> > > > > > > This is the first line n This is the second line
> > > > > > >
> > > > > > >
> > > > > > > Anyone knows why and how to deal with it?
> > > > > > >
> > > > > > > I have to read lots of texts from external files.
> > > > > > > So it is impossible to do it in the first way to directly put the
> > > > > > > texts there, but to read texts each time.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Thanks in advance for any kind reply!
> > > > > > >
> > > > > > > Cheers,
> > > > > > >
> > > > > > > Fan
> > > > > > >
> > > > > > > ------------------
> > > > > > > Read this topic online here:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > >
> > > > >
> > > > > >
> > > > > > > http://forum.openscenegraph.org/viewtopic.php?p=56110#56110
> > > > > > > (http://forum.openscenegraph.org/viewtopic.php?p=56110#56110)
> > > > > > > (http://forum.openscenegraph.org/viewtopic.php?p=56110#56110
> > > > > > > (http://forum.openscenegraph.org/viewtopic.php?p=56110#56110))
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > osg-users mailing list
> > > > > > >
> > > > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > > > >
> > > > > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > > > > > >
> > > > > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > > > >
> > > > > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org))
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > osg-users mailing list
> > > > > >
> > > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > > >
> > > > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > > > > >
> > > > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > > >
> > > > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org))
> > > > > >
> > > > > > ------------------
> > > > > > Post generated by Mail2Forum
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > ------------------
> > > > > Read this topic online here:
> > > > >
> > > >
> > >
> > >
> > > >
> > > > > http://forum.openscenegraph.org/viewtopic.php?p=56116#56116
> > > > > (http://forum.openscenegraph.org/viewtopic.php?p=56116#56116)
> > > > > (http://forum.openscenegraph.org/viewtopic.php?p=56116#56116
> > > > > (http://forum.openscenegraph.org/viewtopic.php?p=56116#56116))
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > osg-users mailing list
> > > > > ()
> > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > >
> > > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > > > >
> > > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > >
> > > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org))
> > > > >
> > > > >
> > > >
> > > >
> > > > ------------------
> > > > Post generated by Mail2Forum
> > > >
> > >
> > >
> > > ------------------
> > > Read this topic online here:
> > >
> > > http://forum.openscenegraph.org/viewtopic.php?p=56118#56118
> > > (http://forum.openscenegraph.org/viewtopic.php?p=56118#56118)
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > osg-users mailing list
> > > ()
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > >
> > >
> > >
> >
> >
> > ------------------
> > Post generated by Mail2Forum
>
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56122#56122
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org