![Smile :)](./images/smilies/icon_smile.gif)
Please check out the thread:
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=60341
How is this properly done? I need to be able to differentiate between UI click/drags (e.g. dragging a window around) and manipulating the Ogre scene.
Cheers,
Michael
Moderators: CEGUI MVP, CEGUI Team
Code: Select all
<?xml version="1.0" ?>
<GUILayout>
<Window Type="DefaultGUISheet" Name="generat0r_MainMenu">
<Property Name="UnifiedSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Window Type="Vanilla/Menubar" Name="generat0r/Menubar">
<Property Name="UnifiedSize" Value="{{1,0},{0.025,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Window Type="Vanilla/MenuItem" Name="generat0r/Menubar/MenuItem1">
<Property Name="UnifiedSize" Value="{{1,0},{0.025,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Property Name="Text" Value="File" />
<Window Type="Vanilla/PopupMenu" Name="generat0r/Menubar/MenuItem1/PopupMenu1">
<Property Name="UnifiedSize" Value="{{1,0},{0.1,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Window Type="Vanilla/MenuItem" Name="generat0r/Menubar/MenuItem1/PopupMenu1/MenuItem1">
<Property Name="UnifiedSize" Value="{{1,0},{0.025,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Property Name="Text" Value="Exit" />
</Window>
</Window>
</Window>
<Window Type="Vanilla/MenuItem" Name="generat0r/Menubar/MenuItem2">
<Property Name="UnifiedSize" Value="{{1,0},{0.1,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Property Name="Text" Value="Help" />
<Window Type="Vanilla/PopupMenu" Name="generat0r/Menubar/MenuItem2/PopupMenu1">
<Property Name="UnifiedSize" Value="{{1,0},{0.1,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Window Type="Vanilla/MenuItem" Name="generat0r/Menubar/MenuItem2/PopupMenu1/MenuItem1">
<Property Name="UnifiedSize" Value="{{1,0},{0.025,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Property Name="Text" Value="About generat0r" />
</Window>
</Window>
</Window>
</Window>
</Window>
</GUILayout>
Code: Select all
<Property Name="UnifiedSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
Code: Select all
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::System &sys = CEGUI::System::getSingleton();
CEGUI::Window* guiW = wmgr.getWindow("uiRoot");
std::string s1 = "UI Element under mouse: " ;
CEGUI::Window* mWin = sys.getWindowContainingMouse();
std::string s2 = mWin->getName().c_str();
std::string s3 = s1 + s2;
mTrayMgr->showOkDialog("UI Element Message", s3);
Code: Select all
CEGUI::Window *mainMenu = wmgr.loadWindowLayout("g0_mainmenu.layout");
mainMenu->setMousePassThroughEnabled(true);
uiRoot->addChildWindow(mainMenu);
Code: Select all
bool BaseApplication::mouseMoved( const OIS::MouseEvent &arg )
{
CEGUI::System &sys = CEGUI::System::getSingleton();
if(sys.injectMousePosition(arg.state.X.abs, arg.state.Y.abs)) //If true the CEGUI needs to handle it !
{
// Scroll wheel.
if (arg.state.Z.rel)
sys.injectMouseWheelChange(arg.state.Z.rel / 120.0f);
}
else
{
if (mTrayMgr->injectMouseMove(arg)) return true;
mCameraMan->injectMouseMove(arg);
}
return true;
}
bool BaseApplication::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
if( ! CEGUI::System::getSingleton().injectMouseButtonDown(convertButton(id))) // if this is true, CEGUI handled the mouse so ogre does not need to!
{
if (mTrayMgr->injectMouseDown(arg, id)) return true;
mCameraMan->injectMouseDown(arg, id);
}
return true;
}
bool BaseApplication::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
if( ! CEGUI::System::getSingleton().injectMouseButtonDown(convertButton(id))) // if this is true, CEGUI handled the mouse so ogre does not need to!
{
if (mTrayMgr->injectMouseUp(arg, id)) return true;
mCameraMan->injectMouseUp(arg, id);
}
return true;
}
Code: Select all
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
uiRoot = wmgr.createWindow( "DefaultWindow", "uiRoot" );
uiRoot->setMousePassThroughEnabled(true);
CEGUI::System::getSingleton().setGUISheet(uiRoot);
CEGUI::Window *mainMenu = wmgr.loadWindowLayout("g0_mainmenu.layout");
uiRoot->addChildWindow(mainMenu);
Code: Select all
<?xml version="1.0" ?>
<GUILayout>
<Window Type="Vanilla/Menubar" Name="generat0r/Menubar">
<Property Name="UnifiedSize" Value="{{1,0},{0.025,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Window Type="Vanilla/MenuItem" Name="generat0r/Menubar/MenuItem1">
<Property Name="UnifiedSize" Value="{{1,0},{0.025,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Property Name="Text" Value="File" />
<Window Type="Vanilla/PopupMenu" Name="generat0r/Menubar/MenuItem1/PopupMenu1">
<Property Name="UnifiedSize" Value="{{1,0},{0.1,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Window Type="Vanilla/MenuItem" Name="generat0r/Menubar/MenuItem1/PopupMenu1/MenuItem1">
<Property Name="UnifiedSize" Value="{{1,0},{0.025,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Property Name="Text" Value="Exit" />
</Window>
</Window>
</Window>
<Window Type="Vanilla/MenuItem" Name="generat0r/Menubar/MenuItem2">
<Property Name="UnifiedSize" Value="{{1,0},{0.1,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Property Name="Text" Value="Help" />
<Window Type="Vanilla/PopupMenu" Name="generat0r/Menubar/MenuItem2/PopupMenu1">
<Property Name="UnifiedSize" Value="{{1,0},{0.1,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Window Type="Vanilla/MenuItem" Name="generat0r/Menubar/MenuItem2/PopupMenu1/MenuItem1">
<Property Name="UnifiedSize" Value="{{1,0},{0.025,0}}" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Property Name="Text" Value="About generat0r" />
</Window>
</Window>
</Window>
</Window>
</GUILayout>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<GUILayout >
<Window Type="Vanilla/FrameWindow" Name="generat0r/AboutDialog" >
<Property Name="Text" Value="About generat0r" />
<Property Name="TitlebarFont" Value="Arial-14" />
<Property Name="TitlebarEnabled" Value="True" />
<Property Name="CloseButtonEnabled" Value="False" />
<Property Name="SizingEnabled" Value="False" />
<Property Name="UnifiedAreaRect" Value="{{0.015,0},{0.015,0},{0.45,0},{0.40,0}}" />
<Property Name="UnifiedPosition" Value="{ {0.25, 0}, {0.25, 0} }" />
<Window Type="Vanilla/StaticText" Name="generat0r/AboutDialog/StaticText" >
<Property Name="Text" Value="Demonstrates static (non editable) text. Use the controls on your right for formatting options." />
<Property Name="HorzExtent" Value="361" />
<Property Name="VertExtent" Value="59.5854" />
<Property Name="HorzFormatting" Value="WordWrapLeftAligned" />
<Property Name="VertFormatting" Value="TopAligned" />
<Property Name="UnifiedAreaRect" Value="{{0.03,0},{0.03,0},{0.97,0},{0.85,0}}" />
</Window>
<Window Type="Vanilla/Button" Name="generat0r/AboutDialog/CloseButton" >
<Property Name="Text" Value="Close" />
<Property Name="UnifiedAreaRect" Value="{{0.42,0},{0.88,0},{0.60,0},{0.955,0}}" />
</Window>
</Window>
</GUILayout>
mboeni wrote:Code: Select all
bool BaseApplication::mouseMoved( const OIS::MouseEvent &arg )
{
CEGUI::System &sys = CEGUI::System::getSingleton();
if(sys.injectMousePosition(arg.state.X.abs, arg.state.Y.abs)) //If true the CEGUI needs to handle it !
{
// Scroll wheel.
if (arg.state.Z.rel)
sys.injectMouseWheelChange(arg.state.Z.rel / 120.0f);
}
else
{
if (mTrayMgr->injectMouseMove(arg)) return true;
mCameraMan->injectMouseMove(arg);
}
return true;
}
Code: Select all
bool Utility::isMouseOverUI()
{
bool condition = false;
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::System &sys = CEGUI::System::getSingleton();
CEGUI::Window* guiW = wmgr.getWindow("uiRoot");
if(sys.getWindowContainingMouse()!=guiW) //this means the mouse is over any UI element
condition = true;
return condition;
}
Code: Select all
bool BaseApplication::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
if(Utility::isMouseOverUI())
{
CEGUI::System::getSingleton().injectMouseButtonDown(convertButton(id));
}
else
{
if (mTrayMgr->injectMouseDown(arg, id)) return true;
mCameraMan->injectMouseDown(arg, id);
}
return true;
}
Code: Select all
if (mTrayMgr->injectMouseUp(arg, id)) return true;
mCameraMan->injectMouseUp(arg, id);
CEGUI::System::getSingleton().injectMouseButtonUp(convertButton(id));
return true;
Code: Select all
if (mTrayMgr->injectMouseMove(arg)) return true;
mCameraMan->injectMouseMove(arg);
CEGUI::System &sys = CEGUI::System::getSingleton();
sys.injectMousePosition(arg.state.X.abs, arg.state.Y.abs);
// Scroll wheel.
if (arg.state.Z.rel)
sys.injectMouseWheelChange(arg.state.Z.rel / 120.0f);
return true;
Users browsing this forum: No registered users and 8 guests