Coordinates for mouse events on widgets

simed

24-10-2011 16:36:07

I noticed in mouse event handlers, the passed mouse coords seem to be screen coords, not local coords to the control receiving the event. It looks like this should work, but I'm not sure if it would correctly handle margins or any other problems:
void MyClass::onMouseUp(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
{
int localTop = _top - _sender->getAbsoluteTop();
int localLeft = _left - _sender->getAbsoluteLeft();
...
}
Could you confirm this is OK, or if not suggest the proper approach?

Altren

25-10-2011 12:06:52

This is correct.