Getting to men-u

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

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Getting to men-u

Postby spannerman » Wed Nov 23, 2005 02:12

Hi guys,
just wanted to check if I’ve got this right, I couldn’t find any examples or full code showing how to make a menu and it’s the first time I’m using one.

1) Order of menu sub parts:

So you need a menubar,
To this you can add multiple MenuItems,
To the menuItems you add a PopupMenu via setPopupMenu,
To the PopupMenu you add multiple ItemEntry’s.

This seems to be working so far; is this the correct way to do it?

2) I have another question. I noticed that when you click on a menuitem, it displays its popupMenu and the items, but this popupMenu does not close unless you click on one of the popupMenu items.

I guess what Im after is that when a Menu popupMenu is open and the user clicks elsewhere in the system or moves the mouse away from the menu then this popupmenu should close. Otherwise it just remains open forcing the user to click an item in it to close it.
Ive tried using a MouseLeaves event on the popupmenu, but the mouse leavable area of the popumenu does not take into account its items, so you move the mouse over the popupmenu items and the popupmenu MouseLeaves event is triggered. Not the desired behaviour.
Hmm is there like a focus lost event or something for the popupmenu and all its items? Have I missed something really obvious?

User avatar
martignasse
Just can't stay away
Just can't stay away
Posts: 227
Joined: Thu Apr 14, 2005 08:10
Location: Lyon, FRANCE

Re: Getting to men-u

Postby martignasse » Fri Nov 25, 2005 18:13

So you need a menubar,
To this you can add multiple MenuItems,
To the menuItems you add a PopupMenu via setPopupMenu,
To the PopupMenu you add multiple ItemEntry’s.

This seems to be working so far; is this the correct way to do it?
sound good to me.

i'v made a sample project to test that some times ago
(and not yet on the wiki.....shame on me)

basicly, it look like this :

Code: Select all

   // create menu bar window
   Menubar* menuBar = static_cast<Menubar*>(winMgr.createWindow("WindowsLook/Menubar", "Menubar"));
   menuBar->setWindowPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
   menuBar->setWindowSize(UVector2(cegui_reldim(1.0f), UDim( 0.0f, 30.0f)));
   menuBar->setWindowMaxSize(UVector2(cegui_reldim(1.0f), UDim( 0.0f, 30.0f)));
   menuBar->setWindowMinSize(UVector2(cegui_reldim(1.0f), UDim( 0.0f, 30.0f)));

   d_root->addChildWindow(menuBar);

   // create file menu item window
   MenuItem* menuFile = static_cast<MenuItem*>(winMgr.createWindow("WindowsLook/MenuItem", "File"));
   menuFile->setText("File");
   menuBar->addItem(menuFile);
   
   // create file menu popup window
   PopupMenu* popupmenuFile = static_cast<PopupMenu*>(winMgr.createWindow("WindowsLook/PopupMenu", "popFile"));
   menuFile->setPopupMenu(popupmenuFile);
   
   // create exit popup item window
   MenuItem* itemExit = static_cast<MenuItem*>(winMgr.createWindow("WindowsLook/MenuItem", "Exit"));
   itemExit->setText("Exit");
   
   popupmenuFile->addItem(itemExit);



I have another question. I noticed that when you click on a menuitem, it displays its popupMenu and the items, but this popupMenu does not close unless you click on one of the popupMenu items.
yep, i noticed that too.

you'r guess is mine :)

User avatar
martignasse
Just can't stay away
Just can't stay away
Posts: 227
Joined: Thu Apr 14, 2005 08:10
Location: Lyon, FRANCE

Re: Getting to men-u

Postby martignasse » Fri Nov 25, 2005 18:18

hehe

and you can find a "in situation" example of menu use in the source code of TestaSkin ;)

sorry, just an egocentric reminder :oops:

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Re: Getting to men-u

Postby spannerman » Sun Nov 27, 2005 16:02

Hehe cool, thanks mate :)

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

Re: Getting to men-u

Postby pabloa » Mon Nov 28, 2005 16:12

I have just see my taharezlook and my Windowslook schemes and I have not have any taharezlook/MenuBar or Windowslook/MenuBar. why? i want to test it too

User avatar
martignasse
Just can't stay away
Just can't stay away
Posts: 227
Joined: Thu Apr 14, 2005 08:10
Location: Lyon, FRANCE

Re: Getting to men-u

Postby martignasse » Mon Nov 28, 2005 17:44

I have just see my taharezlook and my Windowslook schemes and I have not have any taharezlook/MenuBar or Windowslook/MenuBar. why? i want to test it too
Be sure to use at least the 0.4 CEGUI version. and you should use the falagard version of these looks, named "TaharezLookSkin" and "WindowsLookSkin", if i remember correctly.

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

Re: Getting to men-u

Postby pabloa » Mon Nov 28, 2005 18:10

I dont have them, I use de CEGUI that came with ogre. I have them in the source code downloads of this page. What files I have to copy only the .schemes?

Thanks!

User avatar
martignasse
Just can't stay away
Just can't stay away
Posts: 227
Joined: Thu Apr 14, 2005 08:10
Location: Lyon, FRANCE

Re: Getting to men-u

Postby martignasse » Tue Nov 29, 2005 11:49

you have two possibility :

-compile the 0.4 version and integrate it with orge.
(i can't help you on that, never did before)
for this, you should found help here or on orge forums.

-wait for the next orge distrib that should have a 0.4x CEGUI version.

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

Re: Getting to men-u

Postby pabloa » Wed Dec 14, 2005 17:03

I have just update my cegui to 0.4.1 Now I can use Windowslook :lol:

I have modified the code to this

Code: Select all

  CEGUI::Menubar* menu = (CEGUI::Menubar*)CEGUI::WindowManager::getSingleton().createWindow("WindowsLook/Menubar", (CEGUI::utf8*)"menu");
    mEditorGuiSheet->addChildWindow(menu);
    menu->setPosition(CEGUI::Point(0.0f, 0.0f));
    menu->setSize(CEGUI::Size(1.0f, 0.03f));

    CEGUI::MenuItem* mfile = (CEGUI::MenuItem*)CEGUI::WindowManager::getSingleton().createWindow("WindowsLook/MenubarItem", (CEGUI::utf8*)"mfile");
    mEditorGuiSheet->addChildWindow(mfile);
    mfile->setText("File");
   menu->addItem(mfile);

   CEGUI::PopupMenu* popupmfile = (CEGUI::PopupMenu*)CEGUI::WindowManager::getSingleton().createWindow("WindowsLook/PopupMenuItem", (CEGUI::utf8*)"popupmfile");
   mfile->setPopupMenu(popupmfile);

   /*CEGUI::MenuItem* itemexit=(CEGUI::MenuItem*)CEGUI::WindowManager::getSingleton().createWindow("WindowsLook/MenubarItem", (CEGUI::utf8*)"exit");
   itemexit->setText("Exit");
   
   popupmfile->addItem(itemexit);*/

and work fine so, but I dont know why if I use the /* code */ give me a problem with the mouse event (Which It worked perfect without /*code*/)
the mouse event is:

Code: Select all

 void mouseMoved (MouseEvent *e)
   {
       CEGUI::System::getSingleton().injectMouseMove(
               e->getRelX() * mGUIRenderer->getWidth(),
               e->getRelY() * mGUIRenderer->getHeight());
       e->consume();
   }

And I think is perfect because I copied it 8)


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests