Commits

Paweł Wieczorek committed f658677 Draft

added mousedown event'

Comments (0)

Files changed (4)

   | Continue
   | ChangeScreen of screen_handle
 and screen_handle =
-    { screen_draw    : Video.image -> screen_action
-    ; screen_keydown : Input.key -> screen_action
-    ; screen_mouseup : int -> int -> screen_action
+    { screen_draw      : Video.image -> screen_action
+    ; screen_keydown   : Input.key -> screen_action
+    ; screen_mouseup   : int -> int -> screen_action
+    ; screen_mousedown : int -> int -> screen_action
+
     }
 
 (**************************************************************************
  *)
 
 let dummy_screen =
-    { screen_draw    = (fun _ -> Continue)
-    ; screen_keydown = (fun _ -> Continue)
-    ; screen_mouseup = (fun _ _ -> Continue)
+    { screen_draw      = (fun _ -> Continue)
+    ; screen_keydown   = (fun _ -> Continue)
+    ; screen_mouseup   = (fun _ _ -> Continue)
+    ; screen_mousedown = (fun _ _ -> Continue)
     }
     { screen_draw : Video.image -> screen_action
     ; screen_keydown : Input.key -> screen_action
     ; screen_mouseup : int -> int -> screen_action
+    ; screen_mousedown : int -> int -> screen_action
     }
 
 (**************************************************************************

src/Screens/MainScreen.ml

   | _ ->
       Continue
 
+let _screen_mouseup state mx my =
+  Printf.printf "Mouse up at (%u, %u)\n%!" mx my;
+  Continue
+
+let _screen_mousedown state mx my =
+  Printf.printf "Mouse down at (%u, %u)\n%!" mx my;
+  Continue
+
 (**************************************************************************
  * Creator
  *)
     } in
   let mainScreen =
     { dummy_screen with
-      screen_draw    = _screen_draw img fresh_state
-    ; screen_keydown = _screen_keydown fresh_state 
+      screen_draw      = _screen_draw img fresh_state
+    ; screen_keydown   = _screen_keydown fresh_state 
+    ; screen_mouseup   = _screen_mouseup fresh_state
+    ; screen_mousedown = _screen_mousedown fresh_state
     } in
   fresh_state.subscreens.play_screen    <- mainScreen;
   fresh_state.subscreens.options_screen <- mainScreen;
         begin match event with
           | KEYDOWN {keysym = KEY_F12} ->
               state.quit <- true
+
           | KEYDOWN {keysym = key} ->
               let res = state.current_screen.screen_keydown key in
               handle_screen_action state res
+
           | MOUSEBUTTONUP e ->
               let res = state.current_screen.screen_mouseup e.mbe_x e.mbe_y in
               handle_screen_action state res
+
+          | MOUSEBUTTONDOWN e ->
+              let res = state.current_screen.screen_mousedown e.mbe_x e.mbe_y in
+              handle_screen_action state res
+
           | _ ->
               ()
         end;