diff --git a/src/main/scala/ocelot/desktop/ui/widget/EventHandlers.scala b/src/main/scala/ocelot/desktop/ui/widget/EventHandlers.scala index 70a15f7..1288216 100644 --- a/src/main/scala/ocelot/desktop/ui/widget/EventHandlers.scala +++ b/src/main/scala/ocelot/desktop/ui/widget/EventHandlers.scala @@ -2,10 +2,10 @@ package ocelot.desktop.ui.widget import ocelot.desktop.ui.event.Event -import scala.collection.mutable.ListBuffer +import scala.collection.mutable.ArrayBuffer class EventHandlers extends PartialFunction[Event, Unit] { - private val handlers = new ListBuffer[EventHandler] + private val handlers = ArrayBuffer.empty[EventHandler] def +=(handler: EventHandler): Unit = handlers += handler @@ -19,9 +19,7 @@ class EventHandlers extends PartialFunction[Event, Unit] { return } - if (handler.isDefinedAt(event)) { - handler(event) - } + handler.applyOrElse(event, (_: Event) => ()) } }