Page 1 of 1

Getting to men-u

Posted: Wed Nov 23, 2005 02:12
by spannerman
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?

Re: Getting to men-u

Posted: Fri Nov 25, 2005 18:13
by martignasse
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 :)

Re: Getting to men-u

Posted: Fri Nov 25, 2005 18:18
by martignasse
hehe

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

sorry, just an egocentric reminder :oops:

Re: Getting to men-u

Posted: Sun Nov 27, 2005 16:02
by spannerman
Hehe cool, thanks mate :)

Re: Getting to men-u

Posted: Mon Nov 28, 2005 16:12
by pabloa
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

Re: Getting to men-u

Posted: Mon Nov 28, 2005 17:44
by martignasse
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.

Re: Getting to men-u

Posted: Mon Nov 28, 2005 18:10
by pabloa
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!

Re: Getting to men-u

Posted: Tue Nov 29, 2005 11:49
by martignasse
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.

Re: Getting to men-u

Posted: Wed Dec 14, 2005 17:03
by pabloa
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)