Rollover and Clicking not working

casio

21-12-2008 11:36:30

Hi, I'm having a problem using MYGui. Using the code below I get a window with the gui layout loaded from FL_StartScreen.layout This contains only 3 buttons. It all looks ok but when I move the mouse over any button it doesn't hightlight it, Nor does it go to my onQuit function when I click on the button.

I'm obviously missing something fundamental, any ideas guys?
It's like they are disabled, but I've checked and they are all enabled.

MyGUI looks great by the way. The best one I've seen so far.

Thanks.


MyGUI::Gui * gui = MyGUI::Gui::getInstancePtr();
int width = (int)gui->getViewWidth();
int height = (int)gui->getViewHeight();

MyGUI::FontManager::getInstance().load("core.font");
MyGUI::SkinManager::getInstance().load("core.skin");
MyGUI::LayerManager::getInstance().load("core.layer");
MyGUI::PointerManager::getInstance().load("core.pointer");

MyGUI::StaticImagePtr back = gui->createWidget<MyGUI::StaticImage>("StaticImage", MyGUI::IntCoord(0, 0, width, height), MyGUI::ALIGN_STRETCH, "Back");
back->setImageTexture("FL_StartScreen.jpg");

MyGUI::LayoutManager::getInstance().load("FL_StartScreen.layout");

MyGUI::ButtonPtr button = gui->findWidget<MyGUI::Button>("QUIT");
button->eventMouseButtonClick = MyGUI::newDelegate(this, &Game::onQUIT);
}

void Game::onQUIT(MyGUI::WidgetPtr _sender)
{
INT32 i=0;
}


I should add I'm using the demo_itembox code which has this in it too:

bool BasisManager::mouseMoved( const OIS::MouseEvent &arg )
{
mGUI->injectMouseMove(arg);
return true;
}

bool BasisManager::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
mGUI->injectMousePress(arg, id);
return true;
}

bool BasisManager::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
mGUI->injectMouseRelease(arg, id);
return true;
}


When I create a button dynamically instead of loading a template it
all works fine. Here is the code that works.

MyGUI::ButtonPtr button = gui->createWidget<MyGUI::Button>("Button", 10, 10, 300, 26, MyGUI::ALIGN_DEFAULT , "Main");
button->setCaption("exit");
button->eventMouseButtonClick = MyGUI::newDelegate(this, &Game::onQUIT); // CLASS_POINTER is pointer to instance of a CLASS (usually this)

Altren

21-12-2008 16:52:37

Show your FL_StartScreen.layout. I'm almost sure that you have invisible widget over your buttons.

casio

21-12-2008 20:48:50

Show your FL_StartScreen.layout. I'm almost sure that you have invisible widget over your buttons.

That was quick thanks. Here's the layout:

<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Button" skin="Button" position="480 672 168 40" layer="Back" name="QUIT">
<Property key="Widget_Caption" value="Quit Game"/>
<Property key="Widget_FontHeight" value="26"/>
<Property key="Widget_Alpha" value="0.7"/>
</Widget>
<Widget type="Button" skin="Button" position="288 672 168 40" layer="Back" name="OPTIONS">
<Property key="Widget_Caption" value="Options"/>
<Property key="Widget_FontHeight" value="27"/>
<Property key="Widget_Alpha" value="0.7"/>
<Property key="Widget_Enabled" value="true"/>
</Widget>
<Widget type="Button" skin="Button" position="96 672 168 40" layer="Back" name="STARTGAME">
<Property key="Widget_Caption" value="Start Game"/>
<Property key="Widget_Alpha" value="0.7"/>
<Property key="Widget_FontHeight" value="26"/>
<Property key="Widget_Enabled" value="true"/>
</Widget>
</MyGUI>

Rageous

22-12-2008 14:10:36

You should use separate layer for the button that is higher than "Back" one. "Main" for instance...

casio

22-12-2008 20:03:47

You should use separate layer for the button that is higher than "Back" one. "Main" for instance...

Thanks, That worked!