Page 1 of 1
Stopping my own mouseover events when CEGUI has one
Posted: Fri Sep 16, 2005 13:50
by pokemoen
Hello,
I'd like to stop handling my own mouseover events when the mouse is over a CEGUI widget. I'm aware of the screenToWindow and windowToScreen functions which could be used to create certain zones which, when the mouse is over them, could stop my own mouseover checks. But that isn't the most desireable solution I think, and might get hairy when dialogboxes appear and stuff..
Also I thought of stopping my mouseover-checks whenever the mouseover bool of a widget becomes true, but this would involve having eventhandlers for every single widget and isn't good performance-wise I think...
Any suggestions/ideas? Does CEGUI have a "mouseOverAnyWidget" bool built-in that I don't know of?
Thanks in advance,
Alex
Re: Stopping my own mouseover events when CEGUI has one
Posted: Fri Sep 16, 2005 14:56
by lindquist
take a look at
Code: Select all
CEGUI::System::getWindowContainingMouse
Re: Stopping my own mouseover events when CEGUI has one
Posted: Sun Sep 18, 2005 22:45
by pokemoen
Thanks for the good tip!
Having some probs though, my func only returns true for a combobox I have, the rest of my controls don't...
Here's my code:
Code: Select all
bool SWCCG_GUI::isMouseOverGui(float const& x, float const& y){
using namespace CEGUI;
Window* mouseOverWin = System::getSingleton().getWindowContainingMouse();
CEGUI::String type = mouseOverWin->getType();
if(type == ((utf8*)"DefaultWindow")) return false;
const char* type_c = type.c_str(); // For testing
Rect mouseOverWinRect = mouseOverWin->getRect();
mouseOverWinRect = mouseOverWin->windowToScreen(mouseOverWinRect);
Point* mousePos = new Point(x, (0-y)+600);
if( mouseOverWin == NULL || !mouseOverWinRect.isPointInRect(*mousePos) ){
return false;
} else {
return true;
}
}
Blurry suspicions: Other controls recognized as DefaultWindow? Origin at bottomleft to topleft conversion? Quick pointer-hack on mousePos?
Thanks,
Alex
Re: Stopping my own mouseover events when CEGUI has one
Posted: Mon Sep 19, 2005 09:15
by CrazyEddie
DefaultWindow is the only Window that will return "DefaultWindow" as its type.
The origin for all windows is the top-left.
Your mouseOverWin->getRect() call is probably returning relative co-ords which should be converted to absolute values prior to converting to screen values.
Re: Stopping my own mouseover events when CEGUI has one
Posted: Mon Sep 19, 2005 11:09
by pokemoen
The values in the rect correspond with the screenpositions of the widget pretty much exactly.
I added "mouseOverWinRect = mouseOverWin->relativeToAbsolute(mouseOverWinRect);" just for the heck of it and there's no change in the behaviour... Only widgets of type "TaharezLook/Combobox" return true.
Any other ideas? I find it hard to debug this somehow..
TIA
Alex
Re: Stopping my own mouseover events when CEGUI has one
Posted: Fri Sep 23, 2005 11:56
by pokemoen
Okay, I ditched the doublecheck and now trust CEGUI solely... :/
Here's my code
Code: Select all
bool SWCCG_GUI::isMouseOverGui(float const& x, float const& y){
using namespace CEGUI;
Window* mouseOverWin = System::getSingleton().getWindowContainingMouse();
if (mouseOverWin == NULL) return false;
CEGUI::String type = mouseOverWin->getType();
if(type == ((utf8*)"DefaultWindow")) {
return false;
} else {
return true;
}
}
And that seems to work good enough..
Tnx!
Ltr,
Alex
Re: Stopping my own mouseover events when CEGUI has one
Posted: Sun Sep 25, 2005 08:44
by CrazyEddie
You can always trust cegui
