Event

sfml.window.Event
See theEvent companion object
enum Event

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.

val window: Window = ???
val doSomethingWithTheNewSize: (Int, 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(width, height) => doSomethingWithTheNewSize(width, height)

       // etc...

       case _ => ()

Attributes

Companion
object
Graph
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Type members

Enum entries

final case class Closed()

The window requested to be closed

The window requested to be closed

Attributes

final case class GainedFocus()

The window gained the focus

The window gained the focus

Attributes

final case class KeyPressed(code: Key, scancode: Scancode, alt: Boolean, control: Boolean, shift: Boolean, system: Boolean)

A key was pressed

A key was pressed

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
final case class KeyReleased(code: Key, scancode: Scancode, alt: Boolean, control: Boolean, shift: Boolean, system: Boolean)

A key was released

A key was released

Value parameters

alt

Is the Alt key released?

code

Code of the key that has been released.

control

Is the Control key released?

scancode

Physical code of the key that has been released.

shift

Is the Shift key released?

system

Is the System key released?

Attributes

Companion
object
final case class LostFocus()

The window lost the focus

The window lost the focus

Attributes

final case class MouseButtonPressed(button: Button, x: Int, y: Int)

A mouse button was pressed

A mouse button was pressed

Value parameters

button

Code of the button that has been pressed.

x

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

y

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

Attributes

Companion
object
final case class MouseButtonReleased(button: Button, x: Int, y: Int)

A mouse button was released

A mouse button was released

Value parameters

button

Code of the button that has been released.

x

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

y

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

Attributes

Companion
object
final case class MouseEntered()

The mouse cursor entered the area of the window

The mouse cursor entered the area of the window

Attributes

final case class MouseLeft()

The mouse cursor left the area of the window

The mouse cursor left the area of the window

Attributes

final case class MouseMoved(x: Int, y: Int)

The mouse cursor moved

The mouse cursor moved

Value parameters

x

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

y

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

Attributes

Companion
object
final case class MouseWheelScrolled(wheel: Wheel, delta: Float, x: Int, y: Int)

The mouse wheel was scrolled

The mouse wheel was scrolled

Value parameters

delta

Wheel offset (positive is up/left, negative is down/right). High-precision mice may use non-integral offsets.

wheel

Which wheel (for mice with multiple ones).

x

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

y

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

Attributes

Companion
object
final case class Resized(width: Int, height: Int)

The window was resized

The window was resized

Value parameters

height

New height, in pixels.

width

New width, in pixels.

Attributes

Companion
object
final case class SensorChanged(sensor: Type, x: Float, y: Float, z: Float)

Attributes

Companion
object
final case class TextEntered(unicode: Int)

A character was entered

A character was entered

Value parameters

unicode

UTF-32 Unicode value of the character.

Attributes

Companion
object
final case class TouchBegan(finger: Int, x: Int, y: Int)

A touch event began

A touch event began

Value parameters

finger

Index of the finger in case of multi-touch events.

x

X position of the touch, relative to the left of the owner window.

y

Y position of the touch, relative to the top of the owner window.

Attributes

Companion
object
final case class TouchEnded(finger: Int, x: Int, y: Int)

A touch event ended

A touch event ended

Value parameters

finger

Index of the finger in case of multi-touch events.

x

X position of the touch, relative to the left of the owner window.

y

Y position of the touch, relative to the top of the owner window.

Attributes

Companion
object
final case class TouchMoved(finger: Int, x: Int, y: Int)

A touch moved

A touch moved

Value parameters

finger

Index of the finger in case of multi-touch events.

x

X position of the touch, relative to the left of the owner window.

y

Y position of the touch, relative to the top of the owner window.

Attributes

Companion
object