Skip to content

Commit

Permalink
VerticalWheel was renamed in SFML 3
Browse files Browse the repository at this point in the history
  • Loading branch information
texus committed Dec 16, 2023
1 parent 7f85eb4 commit 7beac4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Backend/Window/SFML/BackendGuiSFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,13 @@ namespace tgui
}
case sf::Event::MouseWheelScrolled:
{
#if SFML_VERSION_MAJOR >= 3
if (eventSFML.mouseWheelScroll.wheel != sf::Mouse::Wheel::Vertical)
return false; // TGUI only handles the vertical mouse wheel
#else
if (eventSFML.mouseWheelScroll.wheel != sf::Mouse::Wheel::VerticalWheel)
return false; // TGUI only handles the vertical mouse wheel
#endif

eventTGUI.type = Event::Type::MouseWheelScrolled;
eventTGUI.mouseWheel.delta = eventSFML.mouseWheelScroll.delta;
Expand Down
12 changes: 12 additions & 0 deletions tests/BackendEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,11 @@ TEST_CASE("[Backend events]")
{
sf::Event eventSFML;
eventSFML.type = sf::Event::MouseWheelScrolled;
#if SFML_VERSION_MAJOR >= 3
eventSFML.mouseWheelScroll.wheel = sf::Mouse::Wheel::Vertical;
#else
eventSFML.mouseWheelScroll.wheel = sf::Mouse::Wheel::VerticalWheel;
#endif
eventSFML.mouseWheelScroll.delta = 2;
eventSFML.mouseWheelScroll.x = 200;
eventSFML.mouseWheelScroll.y = 150;
Expand All @@ -304,7 +308,11 @@ TEST_CASE("[Backend events]")
REQUIRE(eventTGUI.mouseWheel.y == 150);

// We only handle vertical scrolling
#if SFML_VERSION_MAJOR >= 3
eventSFML.mouseWheelScroll.wheel = sf::Mouse::Wheel::Horizontal;
#else
eventSFML.mouseWheelScroll.wheel = sf::Mouse::Wheel::HorizontalWheel;
#endif
REQUIRE(!backendGuiSFML->convertEvent(eventSFML, eventTGUI));
}

Expand Down Expand Up @@ -481,7 +489,11 @@ TEST_CASE("[Backend events]")

// Scroll the mouse wheel on top of the slider and verify that its value changes
eventSFML.type = sf::Event::MouseWheelScrolled;
#if SFML_VERSION_MAJOR >= 3
eventSFML.mouseWheelScroll.wheel = sf::Mouse::Wheel::Vertical;
#else
eventSFML.mouseWheelScroll.wheel = sf::Mouse::Wheel::VerticalWheel;
#endif
eventSFML.mouseWheelScroll.delta = 4;
eventSFML.mouseWheelScroll.x = 260;
eventSFML.mouseWheelScroll.y = 80;
Expand Down

0 comments on commit 7beac4b

Please sign in to comment.