Defines a system event and its parameters.
Event holds all the informations about a system event that just happened.
Events are retrieved using the pollEvent function.
A Event instance contains the type of the event (mouse moved, key pressed, window closed, ...) as well as the details about this particular event.
import sfml.system.Vector2
val window: Window = ???
val doSomethingWithTheNewSize: Vector2[Int] => Unit = ???
for event <- window.pollEvent() do
event match
// Request for closing the window
case Event.Closed() => window.close()
// The escape key was pressed
case Event.KeyPressed(Keyboard.Key.Escape, _, _, _, _, _) => window.close()
// The window was resized
case Event.Resized(size) => doSomethingWithTheNewSize(size)
// etc...
case _ => ()
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Members list
Type members
Enum entries
Closed event subtype.
Closed event subtype.
Attributes
Gained focus event subtype
Gained focus event subtype
Attributes
Lost focus event subtype.
Lost focus event subtype.
Attributes
Key pressed event subtype.
Key pressed event subtype.
Value parameters
- alt
-
Is the Alt key pressed?
- code
-
Code of the key that has been pressed.
- control
-
Is the Control key pressed?
- scancode
-
Physical code of the key that has been pressed.
- shift
-
Is the Shift key pressed?
- system
-
Is the System key pressed?
Attributes
- Companion
- object
Key released event subtype.
Key released event subtype.
Value parameters
- alt
-
Is the Alt key pressed?
- code
-
Code of the key that has been released.
- control
-
Is the Control key pressed?
- scancode
-
Physical code of the key that has been released.
- shift
-
Is the Shift key pressed?
- system
-
Is the System key pressed?
Attributes
- Companion
- object
Mouse move raw event subtype.
Mouse move raw event subtype.
Raw mouse input data comes unprocessed from the operating system hence "raw". While the MouseMoved position value is dependent on the screen resolution, raw data is not. If the physical mouse is moved too little to cause the screen cursor to move at least a single pixel, no MouseMoved event will be generated. In contrast, any movement information generated by the mouse independent of its sensor resolution will always generate a MouseMovedRaw event.
In addition to screen resolution independence, raw mouse data also does not have mouse acceleration or smoothing applied to it as MouseMoved does.
Raw mouse movement data is intended for controlling non-cursor movement, e.g. controlling the camera orientation in a first person view, whereas MouseMoved is intended primarily for controlling things related to the screen cursor hence the additional processing applied to it.
Currently, raw mouse input events will only be generated on Windows and Linux.
Value parameters
- delta
-
Delta movement of the mouse since the last event.
Attributes
- Companion
- object
Mouse wheel scrolled event subtype.
Mouse wheel scrolled event subtype.
Value parameters
- delta
-
Wheel offset (positive is up/left, negative is down/right). High-precision mice may use non-integral offsets.
- position
-
Position of the mouse pointer, relative to the top left of the owner window.
- wheel
-
Which wheel (for mice with multiple ones).
Attributes
- Companion
- object
Resized event subtype.