I'm using borderless style for my window. I've set up an area where you can click and drag the window itself. My issue is keeping the mouse inside the window. I remember reading a reply in a thread about this too but still unsure of it.
int main (int argc, char **argv) {
-- Snip --
while (root.GetGameState() != Root::GameState::Quit) {
switch (root.GetGameState()) {
case Root::GameState::Menu:
sf::Event currentEvent;
while (root.GetRenderWindow()->pollEvent(currentEvent)) {
switch (currentEvent.type) {
case sf::Event::MouseButtonPressed:
Utilities::currentMouseButton = currentEvent.mouseButton.button;
Utilities::lastMousePosition = sf::Mouse::getPosition(*root.GetRenderWindow());
break;
case sf::Event::MouseButtonReleased:
Utilities::lastMousePosition = sf::Mouse::getPosition(*root.GetRenderWindow());
-- Snip --
break;
case sf::Event::MouseEntered:
Utilities::mouseWithinWindow = true;
break;
case sf::Event::MouseLeft:
Utilities::mouseWithinWindow = false;
break;
default:
break;
}
if (Utilities::IsMouseButtonHeld(sf::Mouse::Button::Left)) {
root.GetTitleBar()->HandleDrag(root.GetRenderWindow());
}
}
root.GetRenderWindow()->clear(sf::Color(48, 48, 48, 255));
root.Update();
root.GetRenderWindow()->display();
break;
case Root::GameState::Quit:
root.GetRenderWindow()->close();
break;
default:
break;
}
}
return root.GetExitStatus();
}