lib/sdl: add `is_[left|right|middle|wheel]_button`
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 5 Dec 2014 16:03:56 +0000 (11:03 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 8 Dec 2014 18:47:48 +0000 (13:47 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/sdl.nit

index 5a1616d..5225f9f 100644 (file)
@@ -280,6 +280,24 @@ class SDLMouseButtonEvent
        redef var pressed: Bool
        redef fun depressed: Bool do return not pressed
 
+       # Is this event raised by the left button?
+       fun is_left_button: Bool do return button == 1
+
+       # Is this event raised by the right button?
+       fun is_right_button: Bool do return button == 2
+
+       # Is this event raised by the middle button?
+       fun is_middle_button: Bool do return button == 3
+
+       # Is this event raised by the wheel going down?
+       fun is_down_wheel: Bool do return button == 4
+
+       # Is this event raised by the wheel going up?
+       fun is_up_wheel: Bool do return button == 5
+
+       # Is this event raised by the wheel?
+       fun is_wheel: Bool do return is_down_wheel or is_up_wheel
+
        init (x, y: Float, button: Int, pressed: Bool)
        do
                super(x, y)