Some questions about getText() and setText() in lua

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

kitejohn
Just popping in
Just popping in
Posts: 4
Joined: Fri Apr 28, 2006 08:23
Location: china
Contact:

Some questions about getText() and setText() in lua

Postby kitejohn » Fri Feb 02, 2007 03:41

Sample_Demo8:
code as follows:
local text = winMgr:getWindow("Demo8/Window1/Controls/Editbox"):getText()
winMgr:getWindow("Demo8/Window1/Controls/Editbox"):setText(text)

if the string text contains Chinese characters,then i call setText(text),now
you can't see the text of editbox,it has been confused,you just can view another symbol.

I use font simhei-12.font, you can set Chinese characters in c++ code,
for example setText((utf8*)"中"),the editbox can show right, but call
getText() then call setText() in lua,it fails.
Glad to meet all friends here,I think I can take happy to you all!

amugana
Just popping in
Just popping in
Posts: 1
Joined: Wed Feb 07, 2007 09:22

it's because of tolua++

Postby amugana » Sat Feb 10, 2007 09:31

tolua++ simply maps lua 'string' as CEGUI::String. and tolua++ deals strings as 'const char*'

when u call 'Window::getText',, CEGUI::String automatically decode utf32 string to utf8 and returns utf8 pointer, then 'Window::setText' gets it as 'const char*' so.. CEGUI::String do the encode to utf8 again,,

i got the same prob. in korean lua scripting,, and i got a temporal solution that casting NOT 'const char*' but 'utf8' (in lua_CEGUI.cpp)
so it works for me..

sorry for short english, good luck

kitejohn
Just popping in
Just popping in
Posts: 4
Joined: Fri Apr 28, 2006 08:23
Location: china
Contact:

to amugana

Postby kitejohn » Tue Feb 13, 2007 14:01

amugana sir:
thank you for your kind suggesting and detail decription,and also i will try to find another solution for this,no same way but same aim.
good luck to you.
john.
Glad to meet all friends here,I think I can take happy to you all!


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 6 guests