Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Confusion while Reading the documentation on : Events  (Read 3434 times)

0 Members and 1 Guest are viewing this topic.

Power

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Confusion while Reading the documentation on : Events
« on: March 09, 2020, 07:59:52 pm »
Hello,

(I am still new to c++, but i made quite lot of progress, i am not a computer science student although.)

I have a question that could appear "non intelligent" but it kinda confused me. Here it is:
While using the "window" module, its functions were easy to use and pretty straighforward (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Window.php)
The "Public Member Functions" section contains all the functions at one glance, for instance i can use window1.isOpen() if i created and object called window1 from the classe Window.

But then i went to the event page (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Event.php)
because i wanted to check an example that i had read from here : https://www.sfml-dev.org/tutorials/2.5/window-events.php which is below:
         
  if (event.type == sf::Event::MouseWheelScrolled)

 {
 if (event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel)
   cout << "wheel type: vertical" << endl;
else if (event.mouseWheelScroll.wheel == sf::Mouse::HorizontalWheel)
 cout << "wheel type: horizontal" << endl;
else
 cout << "wheel type: unknown" << endl;
 cout << "wheel movement: " << event.mouseWheelScroll.delta << endl; // this line
 cout << "mouse x: " << event.mouseWheelScroll.x << endl;
   cout << "mouse y: " << event.mouseWheelScroll.y << endl;
                }
I got confused when i read this part "  event.mouseWheelScroll.delta",

What is : "mouseWheelScroll"?
It can neither be found on the classes section of the Event pages nor the public types, i can see it on the public Attributes somehow.
Checking the Event.hpp page : https://www.sfml-dev.org/documentation/2.5.1/Event_8hpp_source.php, i don't find "mouseWheelScroll", only "MouseWheelScrollEvent" and "MouseWheelEvent" which are different from "mouseWheelScroll".
As for the "delta" in "event.mouseWheelScroll.delta" no confusion, it's one of variables of the structures i found on the "Event.hpp" page.

Sorry if the answer is obvious, maybe i miss something in c++ that i still need to learn. If yes, please do enlighten me.
Thank you
« Last Edit: March 09, 2020, 08:04:05 pm by Power »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Confusion while Reading the documentation on : Events
« Reply #1 on: March 09, 2020, 10:11:00 pm »
It's there:

     union
     {
         SizeEvent             size;              
         KeyEvent              key;              
         TextEvent             text;              
         MouseMoveEvent        mouseMove;        
         MouseButtonEvent      mouseButton;      
         MouseWheelEvent       mouseWheel;        
         MouseWheelScrollEvent mouseWheelScroll;  
         JoystickMoveEvent     joystickMove;      
         JoystickButtonEvent   joystickButton;    
         JoystickConnectEvent  joystickConnect;  
         TouchEvent            touch;            
         SensorEvent           sensor;            
     };

An instance of the MouseWheelScrollEvent structure, and member of the sf::Event type.

Above is an anonymous union, in case you want to read more about that kind of structure.
« Last Edit: March 09, 2020, 10:12:51 pm by Laurent »
Laurent Gomila - SFML developer

Power

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: Confusion while Reading the documentation on : Events
« Reply #2 on: March 16, 2020, 12:33:59 pm »
It's there:

     union
     {
         SizeEvent             size;              
         KeyEvent              key;              
         TextEvent             text;              
         MouseMoveEvent        mouseMove;        
         MouseButtonEvent      mouseButton;      
         MouseWheelEvent       mouseWheel;        
         MouseWheelScrollEvent mouseWheelScroll;  
         JoystickMoveEvent     joystickMove;      
         JoystickButtonEvent   joystickButton;    
         JoystickConnectEvent  joystickConnect;  
         TouchEvent            touch;            
         SensorEvent           sensor;            
     };

An instance of the MouseWheelScrollEvent structure, and member of the sf::Event type.

Above is an anonymous union, in case you want to read more about that kind of structure.

Thank you.

 

anything