edit box

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Cleves
Posts: 224
Joined: Mon Sep 08, 2003 6:40 pm

edit box

Post by Cleves »

Hey all,

I want to create an edit box but i have some problems, here is my code:
consoleedit=guienv->addEditBox(edit,(0,330,800,350),true,console);
and i defined:
const wchar_t edit[5]='cool';

When I compile it displays the error:"initializing' : cannot convert from 'const int' to 'const unsigned short [5]'
There are no conversions to array types, although there are conversions to references or pointers to arrays"

I know the problem is in wchar_t but I never worked before with wchar and I don't know how to fix it

Thanks
level

Post by level »

hi

const wchar_t edit[5]=L"edit";
Cleves
Posts: 224
Joined: Mon Sep 08, 2003 6:40 pm

Post by Cleves »

Thanks a lot, it works.

I got more Q's tough.Now that I setup the edit box how can the user write inside? I can't find the function.

Thanks
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post by deps »

how can the user write inside?
Uhm? Click inside the editbox and type on the keyboard?
Get the text with editbox->getText();
Cleves
Posts: 224
Joined: Mon Sep 08, 2003 6:40 pm

Post by Cleves »

Hey,

Well, it's not exactly what I need. Is it possiable to start writing in edit box without pressing it first with the mouse? cause when running a 3d application and you enable mouse it's get all buggy and jerky so I can't really move it? is there any way to fix it?

Thanks
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post by deps »

There functions for setting the focus for gui items.
Look into those.
Cleves
Posts: 224
Joined: Mon Sep 08, 2003 6:40 pm

Post by Cleves »

Hey,

Thanks a lot I got it to work.
But I still have one question.How I know when the user pressed enter after he enterd his text? How can i get this text?
Thanks alot.
:D
ErMurazor
Posts: 37
Joined: Sat Dec 13, 2003 2:00 pm
Location: Sweden
Contact:

Post by ErMurazor »

Hi

To catch a enter in a edit box look at gui event EGET_EDITBOX_ENTER

In the doc http://irrlicht.sourceforge.net/docu/na ... i.html#a57

/ErMurazor
Project YAMMO
http://stenhard.net
Cleves
Posts: 224
Joined: Mon Sep 08, 2003 6:40 pm

Post by Cleves »

Thanks guys for your replays but I got one last noob question.
Really sorry for the noobish question.

I use the gettext() to store the editbox input, but can i turn it into text string? cause i want to check what the user puts in, compare with another text and create an effect based on the comparison.

Any ideas?

Thanks
Cleves
Posts: 224
Joined: Mon Sep 08, 2003 6:40 pm

Post by Cleves »

Hey guys,

I really need your help! i'm stuck!^^^^^^^^
joy
Posts: 124
Joined: Tue Apr 27, 2004 9:15 am
Location: Germany

Post by joy »

I know, very very late answer, but may be it can still help.

there is no problem to convert the text into a String. It does it automatically.

m_pWorld->m_Name = m_pNewScreen->m_pEditBox_Welt->getText();

where m_Name is a member variable of CString :
CString m_Name;

so when you geht the text from the editbox it will be stored in m_Name which is a String. If you want a casting now to get from that String a char too, you can do this:

wchar_t tempStr[TMPBUF_SIZE];
_mbstowcsz(tempStr, m_pWorld->m_Name, m_pWorld->m_Name.GetLength() + 1);

and put tempStr where ever you need it. eg: m_pListScreens->addItem(tempStr);
Post Reply