menuItem doesn't change correctly according to mouse cursor?

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

billconan
Just popping in
Just popping in
Posts: 12
Joined: Wed May 17, 2006 14:11

menuItem doesn't change correctly according to mouse cursor?

Postby billconan » Tue Jun 20, 2006 03:52

hi folks, i want to implement a simple menu control with cegui, and the appearance of the menu items should change according to the mouse movement. for example, when the cursor is hovering on the menu item, the color of the menu item becomes dark.

but it seems that things do not go my way. and i have tested that the input is handled correctly. so the problem is most likely due to the wrong definition of the "Area" of the menu items. so could you please help me out?

thanks.

this is the screen shot:
Image

and this is the look and feel definition:

Code: Select all

<WidgetLook name="PolygonStudio/MenuItem">
        <ImagerySection name="label">
            <TextComponent>
                <Area>
           <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                    <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
                </Area>
                <VertFormat type="CentreAligned" />
                <HorzFormat type="LeftAligned" />
            </TextComponent>
        </ImagerySection>
        <StateImagery name="EnabledNormal">
            <Layer>
                <Section section="label" >

</Section>
            </Layer>
        </StateImagery>
        <StateImagery name="EnabledHover">
            <Layer>
                <Section section="label" >
<Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
</Section>
            </Layer>
        </StateImagery>
        <StateImagery name="EnabledPushed">
            <Layer>
                               <Section section="label" >

</Section>
            </Layer>
        </StateImagery>
        <StateImagery name="EnabledPopupOpen">
            <Layer>
                <Section section="label" />
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledNormal">
            <Layer>
                <Section section="label" />
               
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledHover">
            <Layer>
                               <Section section="label" >
<Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
</Section>
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledPushed">
            <Layer>
                <Section section="label">
                    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledPopupOpen">
            <Layer>
                <Section section="label">
                    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
                </Section>
            </Layer>
        </StateImagery>
    </WidgetLook>



<WidgetLook name="PolygonStudio/Menubar">
   <NamedArea name="ItemRenderArea">
                      <Area>
                <Dim type="LeftEdge" ><AbsoluteDim value="120" /></Dim>
                <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                    <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
             </Area>
        </NamedArea>
        <ImagerySection name="frame">
            <FrameComponent>
                <Area>
                    <Dim type="LeftEdge" ><AbsoluteDim value="120" /></Dim>
                    <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                    <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
                </Area>

            </FrameComponent>
        </ImagerySection>
        <StateImagery name="Enabled">
      <Layer>
                <Section section="frame" />
            </Layer>
        </StateImagery>
        <StateImagery name="Disabled">
      <Layer>
                <Section section="frame" />
            </Layer>
        </StateImagery>
    </WidgetLook>
</Falagard>


and this is how i add menu in the code:

Code: Select all

Menubar* menuBar = static_cast<Menubar*>(wmgr.createWindow("PolygonStudio/Menubar", "Menubar"));
theMainFrame->addChildWindow(menuBar);
    menuBar->setText("menu");
    menuBar->setPosition(Point(0, 0));
    menuBar->setSize(Size(0.5f, 0.02f));


 MenuItem* menuFile = static_cast<MenuItem*>(wmgr.createWindow("PolygonStudio/MenuItem", "File"));
   menuBar->addItem(menuFile);
 menuFile->setText("File");
   menuFile->setSize(Size(0.5f, 0.02f));




       MenuItem* menuCreate = static_cast<MenuItem*>(wmgr.createWindow("PolygonStudio/MenuItem", "Create"));
   menuCreate->setText("Create");
   menuBar->addItem(menuCreate);


how i handle the input:

Code: Select all

void inject_input(bool& must_quit)
{
  SDL_Event e;
  //printf("fuck\n");
  // go through all available events
  while (SDL_PollEvent(&e))
  {
    // we use a switch to determine the event type
    switch (e.type)
    {
      // mouse motion handler
      case SDL_MOUSEMOTION:
        // we inject the mouse position directly.
      //  printf("fuck");
        CEGUI::System::getSingleton().injectMousePosition(static_cast<float>(e.motion.x),static_cast<float>(e.motion.y));
        break;
    // mouse down handler
      case SDL_MOUSEBUTTONDOWN:
    // let a special function handle the mouse button down event
   //handle_mouse_down(e.button.button);
        break;
    // mouse up handler
    case SDL_MOUSEBUTTONUP:
        // let a special function handle the mouse button up event
      //handle_mouse_up(e.button.button);
        break;
      // key down
      case SDL_KEYDOWN:
        // to tell CEGUI that a key was pressed, we inject the scancode.
        CEGUI::System::getSingleton().injectKeyDown(e.key.keysym.scancode);
      //exit(0);
        // as for the character it's a litte more complicated. we'll use for translated unicode value.
        // this is described in more detail below.
      printf("%x\n",e.key.keysym.scancode);
      if(e.key.keysym.unicode==0x1b) exit(0);
        if ((e.key.keysym.unicode & 0xFF80) == 0)
        {
          CEGUI::System::getSingleton().injectChar(e.key.keysym.unicode & 0x7F);
        }
        break;
   
      // key up
      case SDL_KEYUP:
        // like before we inject the scancode directly.
        CEGUI::System::getSingleton().injectKeyUp(e.key.keysym.scancode);
        break;
      case SDL_QUIT:
        must_quit = true;
        break;
   
    }
 
  }

Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 7 guests