Page 1 of 1

How to make this kind of window?

Posted: Thu Feb 03, 2011 8:03 am
by wsw1231
Image

It is quite common to see such kind of window but when it comes to do programming to make it, it seems to be quite hard.

How can the program know if the user has selected an option and then it will generate the preview?

How to make the preview? Is it a scene node? or just a 2D picture?

Posted: Thu Feb 03, 2011 8:19 am
by pandoragami
I think example 5 for the user interface is something like that... no?

Posted: Thu Feb 03, 2011 8:47 am
by wsw1231
But example 5 does not show how to get the option that the user chose.
There are 2 possible options in the list box in example 5, which are "File open" and "Window created".

If the user clicks on window created, how can I know?
What should I do in the event receiver?

Posted: Thu Feb 03, 2011 9:44 am
by CuteAlien
You catch the event (EGET_LISTBOX_CHANGED and EGET_LISTBOX_SELECTED_AGAIN for listboxes) in your eventreceiver and act on that. And previews are mostly 2d-images, although in RPG's for example you also often see real 3D models (probably using render-to-texture).

Posted: Thu Feb 03, 2011 1:35 pm
by wsw1231

Code: Select all

if (listBox->getListItem(listBox->getSelected()) == L"ABC")
								Device->closeDevice();
In a list box, I have added an item called "ABC"

So, if I select "ABC", the device should be closed but it is not the case....

Is there something wrong in the if statement?

Posted: Thu Feb 03, 2011 2:28 pm
by CuteAlien
In c++ you can't compare c-strings with ==. This will only check for identical pointers.

You have to either use a string class like core::stringw (probably easiest solution for you) or use the string-compare functions like wstrcmp.

So this should work probably:

Code: Select all

if (stringw(listBox->getListItem(listBox->getSelected())) == stringw(L"ABC")) 

Posted: Thu Feb 03, 2011 7:42 pm
by slavik262
CuteAlien wrote: So this should work probably:

Code: Select all

if (stringw(listBox->getListItem(listBox->getSelected())) == stringw(L"ABC")) 
Or instead of converting to Irrlicht strings, you can use strncmp from the C standard library. It's designed to do string comparisons between C-style strings.