package event
This package constitutes a high-level abstraction of input (e.g., keyboard or mouse) events using an actor event bus.
Such events, if triggered by the drivers, are published to the global
event stream of this package and can be retrieved by subscribing to the
stream
object.
Also, there is a Subscriber
actor that can be used to handle events.
Since version 1.3.0, it's companion object defines to
methods for screens
and worlds with a PartialFunction[Event, Unit]
as a parameter.
So, for example, you just can write
Subscriber.to(world) {
case e: Event ⇒ println(e)
}
to print out all events occurring on the specified world
.
To get the triggering enabled, the withEvents
factory methods of
World
or Screen
have to be used.
Note that the program doesn't terminate by itself on closing all screens if
the event package is used. This is due to background processes still
listening to the event stream. For explicit termination call the terminate
method on the package object's system
value; this can be done, e. g., by
subscribing to all screens or worlds and using a termination event like this:
Subscriber.to(world1, world2) { case KeyEvent(k) if k=='q' ⇒ world1.screen.close() world2.screen.close() println("terminating...") system.terminate() case _: Event ⇒ () }
- Since
1.2.0
- Alphabetic
- By Inheritance
- event
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
sealed
trait
Button
extends AnyRef
Sealed trait of mouse buttons.
Sealed trait of mouse buttons.
- Since
1.2.0
-
type
ClassifiedEvent = (Event, Option[Screen])
An event optionally associated with a screen.
An event optionally associated with a screen.
- Since
1.3.0
-
case class
DragEvent
(button: Button, modifiers: Set[Modifier], position0: Pixel, position1: Pixel) extends Event with Product with Serializable
- position0
the start position of this drag event in coordinates of the related screen
- position1
the end position of this drag event in coordinates of the related screen
-
sealed
trait
Event
extends AnyRef
Sealed trait of input events.
Sealed trait of input events.
- Since
1.2.0
- case class KeyEvent (char: Char) extends Event with Product with Serializable
-
sealed
trait
Modifier
extends AnyRef
Sealed trait of keyboard-modifier keys.
Sealed trait of keyboard-modifier keys.
- Since
1.2.0
-
case class
MouseEvent
(button: Button, modifiers: Set[Modifier], clickCount: Int, position: Pixel) extends Event with Product with Serializable
- position
the position of this mouse event in coordinates of the related screen
- case class OtherButton (number: Int) extends Button with Product with Serializable
-
class
Publisher
extends Actor
Provides an actor publishing
Event
s to the package object's global event stream.Provides an actor publishing
Event
s to the package object's global event stream.- Since
1.2.0
-
class
Subscriber
extends Actor
Provides an actor subscribing to
Event
s received from the package object's global event stream for each of the specified screens.Provides an actor subscribing to
Event
s received from the package object's global event stream for each of the specified screens.- Since
1.2.0
-
case class
WheelEvent
(button: Button, modifiers: Set[Modifier], clickCount: Int, position: Pixel, rotation: Int) extends Event with Product with Serializable
- position
the position of this wheel event in coordinates of the related screen
- rotation
the number of "clicks" the mouse wheel was rotated (negative when up/away from the user, and positive when down/towards the user)
Value Members
-
val
publisher: ActorRef
The actor publishing events to the global event stream that are triggered by drivers and are not associated with a screen.
The actor publishing events to the global event stream that are triggered by drivers and are not associated with a screen.
- Note
As of version 1.3.0, the definition changed from all events to events not associated with a screen.
-
val
stream: ScreenEventBus.type
The event stream global to this package.
The event stream global to this package.
Subscribe to this stream to retrieve triggered events.
- Note
As of version 1.3.0, the definition changed from
EventStream
toScreenEventBus
(both are implementations ofEventBus
) in order to handle events classified by screen.
-
val
system: ActorSystem
The actor system used in this package.
- object AltGraphModifier extends Modifier with Product with Serializable
- object AltModifier extends Modifier with Product with Serializable
- object CtrlModifier extends Modifier with Product with Serializable
- object LeftButton extends Button with Product with Serializable
- object MetaModifier extends Modifier with Product with Serializable
- object MiddleButton extends Button with Product with Serializable
- object NoButton extends Button with Product with Serializable
- object RightButton extends Button with Product with Serializable
-
object
ScreenEventBus
extends EventBus with LookupClassification with ActorEventBus
An event bus for events classified by screen.
An event bus for events classified by screen.
- Since
1.3.0
- object ShiftModifier extends Modifier with Product with Serializable
- object Subscriber