First of all, I want to express my gratitude and respect to developers of this really great library. I find it quite easy-to-use and at the same time very powerful. Great job!
I'm doing small framework to make a GUI based on Graphics package. After polling new event I check it's source (keyboard or mouse). If it's related to mouse, I get cursor position and use it onwards.
window.pollEvent(event);
sf::Vector2i mousePointer(event.mouseMove);
Control* curUnderMouse = nullptr;
...
for(auto control: m_controls)
{
if(control->hitTest(mousePointer))
{
curUnderMouse = control;
break;
}
}
I already realized my fault that event.mouseMove and event.mouseButton store cursor coordinates differently.
struct MouseMoveEvent
{
int x;
int y;
};
struct MouseButtonEvent
{
Mouse::Button button;
int x;
int y;
};
I've corrected my error, but here is my question: won't be better to declare MouseButtonEvent as
struct MouseButtonEvent
{
int x;
int y;
Mouse::Button button;
};
to make user code simpler in many situations? Just because these structs are in union, there will be no need to check mouse event type just to get mouse cursor position.
Anyway, it's really great library and I'm looking forward it's further development. And sorry for my English