Page 1 of 2
How can I get a text from textinput only knowing the id?
Posted: Sat Nov 17, 2007 11:38 am
by sanctus2099
Okay... so I have the id of a gadget in a int
Is there a way to get a pointer to a gadget by the id or anyother way to find out what is in the textinput just by knowing the id?
Re: How can I get a text from textinput only knowing the id?
Posted: Sat Nov 17, 2007 11:52 am
by shogun
sanctus2099 wrote:Okay... so I have the id of a gadget in a int
Is there a way to get a pointer to a gadget by the id or anyother way to find out what is in the textinput just by knowing the id?
((gui::IGUIEditBox*)getElementFromId(YOUR_ID, true))->getText();
getRootGUIElement() also may be of interest for you, if you don't have a IGUIWindow where your Editbox is placed. Just search the docs.
Posted: Sat Nov 17, 2007 12:17 pm
by sanctus2099
Thx dude...
Posted: Mon Nov 26, 2007 11:27 am
by sanctus2099
Okay... I didn't test it back then but I tought it would work(had some other problems).
THe things is that it doesn work... somehow there is no function like getelementfromid. I'd love if the docs would have a search
Posted: Mon Nov 26, 2007 11:57 am
by shogun
Yes, there is such a function.
You can use Google, can't you?
http://irrlicht.sourceforge.net/docu/cl ... nt.html#a6
Posted: Mon Nov 26, 2007 12:39 pm
by sanctus2099
Thx... It works now.
Any ideea how to transform a whcar_t array to a string? I need to send it trough network.
Posted: Mon Nov 26, 2007 12:46 pm
by JP
search the forum as this has be answered lots, or look at core::stringw
Posted: Mon Nov 26, 2007 1:52 pm
by Acki
right, always search the forum first !!!
well, just in case you're to dump to do a search
try this thread:
http://irrlicht.sourceforge.net/phpBB2/ ... rt+convert
but seriously, please search the forums before asking, it usualy will save a lot of time for all of us !!!
Posted: Mon Nov 26, 2007 3:58 pm
by sanctus2099
Okay... my bad... I did look a litle into the search but didn't find exactly what I wanted... its ok now... next problem...
Code: Select all
IGUIElement* elem;
char temp[255];
wcstombs(temp, elem->getElementFromId(nameid)->getText(), 255);
It does compile... but when it passes those lines it breaks and says something about it not beeing defined... could someone please recode that small thing? pls
Posted: Mon Nov 26, 2007 4:14 pm
by CuteAlien
sanctus2099 wrote: ... but when it passes those lines it breaks and says something about it not beeing defined...
Always funny when people try to summarize error messages instead of just pasting them :-) That exact (and complete!) error message is the thing we need to help you ...
Posted: Mon Nov 26, 2007 4:34 pm
by JP
my guess is getElementFromId is returning NULL..
Does getElementFromId only search the children of that element and seeing as elem has just been declared as a solitary element it won't find anything...
Posted: Mon Nov 26, 2007 5:41 pm
by Acki
right, because
IGUIElement* elem; is undefined garbage and you try to get an element from it...
so change
Code: Select all
elem->getElementFromId(nameid)->getText()
to
Code: Select all
guienv->getElementFromId(nameid)->getText()
or whatever your gui environment is defined in...
Posted: Mon Nov 26, 2007 7:00 pm
by sanctus2099
Code: Select all
c:\SanctusOnline\IntfFunctions.cpp(21): error C2039: 'getElementFromId' : is not a member of 'irr::gui::IGUIEnvironment'
c:\SanctusOnline\Irrlicht\IGUIEnvironment.h(55) : see declaration of 'irr::gui::IGUIEnvironment'
I allready tryed that. Is there a way to get the masterparent of all gui elements?
Posted: Mon Nov 26, 2007 7:47 pm
by Acki
sanctus2099 wrote:I allready tryed that. Is there a way to get the masterparent of all gui elements?
ohh, my fault, I just looked at your code and made a quick post...
but why you didn't simply look at the api, it's a realy magical file that tells you all about Irrlicht's elements and their functions !!!
so the code must (of course) be:
Code: Select all
guienv->getRootGUIElement()->getElementFromId(nameid)->getText()
Posted: Tue Nov 27, 2007 2:10 am
by vitek
You're forgetting that you need to tell the call to recursively traverse the element graph...
Code: Select all
gui::IGUIElement* found = gui->getRootElement()->getElementFromId(id, true);
if (found)
{
const wchar_t* wstr = found->getText();
}
Travis