Hello!
First post here. I've tried searching for an answer, but didn't fine one.
I've been using CEGUI for a bit now with Ogre3D. So far, it works pretty well.
Now I wanted to add a simple thing: Scrolling the mouse wheel should move the scroll bar of comboboxes' drop down lists, if the mouse is hovering over them. I can get the window the mouse is hovering over by calling CEGUI::System::getWindowContainingMouse(), which works fine.
However, I seem unable to check whether the Window* I get actually is a Combobox*, ComboDropList* or an Editbox*.
Using dynamic_cast doesn't work and ends with an exception.
Calling getType() on the Window* I receive works, however I don't know what to compare that String against.
So... yeah... would be nice if someone could point me in the right direction.
Finding out what type a window has?
Moderators: CEGUI MVP, CEGUI Team
-
- Quite a regular
- Posts: 60
- Joined: Tue Oct 28, 2008 10:46
- scriptkid
- Home away from home
- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
^^ It can even be done easier
you can use Window::testClassName which accepts a class name from the cegui namespace.
For example to test for combobox, use:
These classnames are case sensitive!
HTH.
you can use Window::testClassName which accepts a class name from the cegui namespace.
For example to test for combobox, use:
Code: Select all
if (win->testClassName("Combobox"))
{
}
These classnames are case sensitive!
HTH.
Check out my released snake game using Cegui!
-
- Quite a regular
- Posts: 60
- Joined: Tue Oct 28, 2008 10:46
The exception thrown said something about the type not being an _rtti type. I'll just check it again before I give scriptkid's solution a try.
edit:
Okay, just tried the dynamic_cast again, here's the exception:
This occurs at "CEGUI::Combobox* cbb = dynamic_cast<CEGUI::Combobox*>(wnd);"
edit:
Okay, just tried the dynamic_cast again, here's the exception:
Unhandled exception at 0x7c812aeb in TankGameW32.exe: Microsoft C++ exception: std::__non_rtti_object at memory location 0x0012f1b4..
This occurs at "CEGUI::Combobox* cbb = dynamic_cast<CEGUI::Combobox*>(wnd);"
matches81 wrote:The exception thrown said something about the type not being an _rtti type. I'll just check it again before I give scriptkid's solution a try.
edit:
Okay, just tried the dynamic_cast again, here's the exception:Unhandled exception at 0x7c812aeb in TankGameW32.exe: Microsoft C++ exception: std::__non_rtti_object at memory location 0x0012f1b4..
This occurs at "CEGUI::Combobox* cbb = dynamic_cast<CEGUI::Combobox*>(wnd);"
Thanks for the info, could you answer a few more questions please.
Which version of Visual Studio?
Which service pack?
Do you have RTTI enabled?
Did you also get a linker warning
I will assume visual studio 2005 and no service pack until you can confirm otherwise, this is a bug which was fixed with sp1.
Last edited by dmail on Tue Dec 23, 2008 17:48, edited 1 time in total.
dmail wrote:Thanks for the info, could you answer a few more questions please.
Which version of Visual Studio?
Which service pack?
Do you have RTTI enabled?
Sure. VS2005 with SP1 (Version 8.0.50727.762 (SP.050727-7600)), Windows XP SP3.
how do I enable RTTI?
Btw: Scriptkid's solution worked flawlessly, thanks for the help.
dmail wrote:Project Properites -> c/c++ -> Language -> Enable RTTI
The problem was that pre sp1 RTTI was enabled whether you asked for it or not, in SP1 it does the correct thing. So if it is not enabled you will get an error.
Well, it seems RTTI is already enabled for the project.
Also, the project currently compiles and links fine without any warnings.
Who is online
Users browsing this forum: No registered users and 24 guests