add callbacks for mouse movement and mouse clicking
This commit is contained in:
17
imperative-shell/input-callbacks.sml
Normal file
17
imperative-shell/input-callbacks.sml
Normal file
@@ -0,0 +1,17 @@
|
||||
structure InputCallbacks =
|
||||
struct
|
||||
open CML
|
||||
open Msg
|
||||
|
||||
fun mouseMoveCallback mailbox (x, y) =
|
||||
Mailbox.send (mailbox, (MOUSE_MOVE {x = x, y = y}))
|
||||
|
||||
fun mouseClickCallback mailbox (button, action) =
|
||||
if button = Input.LEFT_MOUSE_BUTTON () then
|
||||
if action = Input.MOUSE_PRESSED () then
|
||||
Mailbox.send (mailbox, MOUSE_LEFT_CLICK)
|
||||
else
|
||||
Mailbox.send (mailbox, MOUSE_LEFT_RELEASE)
|
||||
else
|
||||
()
|
||||
end
|
||||
Reference in New Issue
Block a user