Add widgetGetCurrentlyMousedOver to return the widget that currently has the mouse over it.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5834 4a71c877-e1ca-e34f-864e-861f7616d084
master
Freddie Witherden 2008-08-17 18:22:38 +00:00
parent eaffd089b3
commit 077cfee020
2 changed files with 37 additions and 1 deletions

View File

@ -1226,6 +1226,31 @@ widget *widgetGetCurrentlyFocused(widget *self)
return self;
}
widget *widgetGetCurrentlyMousedOver(widget *self)
{
int i;
// Make sure we have the mouse
if (!self->hasMouse)
{
return NULL;
}
// See if any of our children are moused over
for (i = 0; i < vectorSize(self->children); i++)
{
widget *child = vectorAt(self->children, i);
if (child->hasMouse)
{
return widgetGetCurrentlyMousedOver(child);
}
}
// None of our children have the mouse; return ourself
return self;
}
bool widgetHandleEventImpl(widget *self, const event *evt)
{
// If the event should be passed onto our children

View File

@ -815,11 +815,22 @@ void widgetDestroy(widget *self);
* Should none of self's child widgets have focus (but it does) then self is
* returned.
*
* @param self The widget to get the further down focused child of.
* @param self The widget to get the furthest down focused child of.
* @return A pointer to the widget, or NULL if self is not focused.
*/
widget *widgetGetCurrentlyFocused(widget *self);
/**
* Very much the same as widgetGetCurrentlyFocused except that it returns a
* pointer to the widget furthest down the hierarchy which currently has the
* mouse over it. Like with widgetGetCurrentlyFocused should self not have the
* mouse over it, NULL is returned.
*
* @param self The widget to get the furthest down moused-over child of.
* @param A pointer to the widget, or NULL if self does not have the mouse.
*/
widget *widgetGetCurrentlyMousedOver(widget *self);
/**
* If the widget is capable of holding keyboard focus and does not currently
* hold it then this method will bring it into focus. Should ->parent not be