MenuItem Fail with "new" Keyword

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Quite a regular
Quite a regular
Posts: 83
Joined: Fri Jan 07, 2011 13:55

MenuItem Fail with "new" Keyword

Postby belkacem » Fri Jul 22, 2011 08:54

hi again !!

the menu widget is one of the control that contain item like list box and combobox
and to create item for menu we use CEGUI::MenuItem .

if i create a menu item like this

Code: Select all

MenuItem *_item = static_cast <MenuItem*> (CEGUI::WindowManager::getSingletonPtr()->createWindow ("TaharezLook/MenuItem" , Name)

and succeeded to create the item but if i change my code to something like this

Code: Select all

CEGUI::MenuItem *_item = new MenuItem ( "TaharezLook/MenuItem" , Name);

i fail to create the menu item

my question is : what's the diferrent between first code and the second
and why i fail to create the item in the second way , and thank you .


Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: MenuItem Fail with "new" Keyword

Postby Jamarr » Fri Jul 22, 2011 19:03

Because WindowManager::createWindow takes a TargetType and MenuItem::MenuItem takes a WindowType. These are not the same thing and these two methods are not equivalent. The WindowManager uses the TargetType to look up the FalagardType, which it uses to assign the appropriate Renderer and LookNFeel references. All of these types are mapped via the .scheme file.

Why do you want to use 'new' instead of the provided WindowManager which encapsulates this whole process? You would need to re-write the functionality of the WindowManager, but why do this when it already exists? Stick with WindowManager::createWindow.

And for future reference, if you want to know how some code works please just look at the source-code yourself. Only then, after looking at the code yourself, should you come to the forums and ask questions if you still need help. That is exactly what we, the helpful community members have to do anyway. Please be considerate of our time, we do not get paid to help people ;)
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests