Commit 9845311f authored by h2b's avatar h2b

Some refinements done.

parent e6d3073f
......@@ -30,10 +30,12 @@ import javax.swing.SwingUtilities
*/
trait AwtEventDriver extends AwtScreenDriver {
import AwtEventDriver._
override protected def keyListenerOption: Option[AwtKeyListener] = Some(KeyListener)
override protected def mouseListenerOption: Option[AwtMouseListener] = Some(MouseListener)
object KeyListener extends AwtKeyListener {
private object KeyListener extends AwtKeyListener {
def keyPressed (e: AwtKeyEvent): Unit = {
//unused in this implementation
......@@ -49,7 +51,7 @@ trait AwtEventDriver extends AwtScreenDriver {
}
object MouseListener extends AwtMouseListener {
private object MouseListener extends AwtMouseListener {
def mouseClicked (e: AwtMouseEvent): Unit = {
publisher ! mouseEvent(e)
......@@ -73,12 +75,18 @@ trait AwtEventDriver extends AwtScreenDriver {
}
private def keyEvent (e: AwtKeyEvent) =
KeyEvent(e.getKeyChar)
private def mouseEvent (e: AwtMouseEvent) =
MouseEvent(button(e), modifiers(e), e.getClickCount, position(e))
private def position (e: AwtMouseEvent) = Pixel(e.getX, flipV(e.getY))
}
object AwtEventDriver {
private def keyEvent (e: AwtKeyEvent) =
KeyEvent(e.getKeyChar)
private def button (e: AwtMouseEvent): Button =
if (SwingUtilities.isLeftMouseButton(e)) LeftButton
else if (SwingUtilities.isRightMouseButton(e)) RightButton
......@@ -98,6 +106,4 @@ trait AwtEventDriver extends AwtScreenDriver {
result
}
private def position (e: AwtMouseEvent) = Pixel(e.getX, flipV(e.getY))
}
......@@ -221,7 +221,7 @@ trait AwtScreenDriver extends ScreenDriver {
object AwtScreenDriver {
private val log = Logger(getClass)
private val log = Logger(getClass) at Level.Error
private val env = GraphicsEnvironment.getLocalGraphicsEnvironment
private val bounds = if (env.isHeadlessInstance()) new Rectangle(0,0,0,0) else env.getMaximumWindowBounds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment