Class SFML::Event::MouseButton
In: window/Event.cpp
Parent: Object

SFML::Event holds all the informations about a system event that just happened.

Events are retrieved using the SFML::Window#GetEvent function.

A SFML::Event instance contains the type of the event (mouse moved, key pressed, window closed, …) as well as the details about this particular event. Please note that the event parameters are defined in a union, which means that only the member matching the type of the event will be properly filled; all other members will have undefined values and must not be read if the type of the event doesn‘t match. For example, if you received a KeyPressed event, then you must read the event.Key

 member, all other members such as event.MouseMove or event.Text will have undefined values.

The ruby version differs from C++ in that the parameters are still stored in a union but that the values can be directly accessed from the event object. If you try to access any data which would be considered undefined then SFML::SomeKindOfException will be thrown.

Usage example:

 while event = window.getEvent()

    # Request for closing the window
    if event.type == SFML::Event::Closed
      window.close

    # The escape key was pressed
    if ( event.type == sf::Event::KeyPressed ) && ( event.code == SFML::Key::Escape )
      window.close

    # The window was resized
    if event.type == SFML::Event::Resized
      DoSomethingWithTheNewSize(event.size);

    # etc ...
  end

Methods

button   x   y  

Public Instance methods

Code of the button that has been pressed.

X position of the mouse pointer, relative to the left of the owner window

Y position of the mouse pointer, relative to the top of the owner window

[Validate]