scaffolding in preparation for implementing undo

This commit is contained in:
2024-08-08 06:34:40 +01:00
parent a53c5e1ce3
commit 5c7c61586a
10 changed files with 53 additions and 10 deletions

View File

@@ -8,10 +8,8 @@ struct
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)
if action = Input.PRESS () then Mailbox.send (mailbox, MOUSE_LEFT_CLICK)
else Mailbox.send (mailbox, MOUSE_LEFT_RELEASE)
else
()
@@ -20,6 +18,13 @@ struct
in Mailbox.send (mailbox, RESIZE_WINDOW {width = width, height = height})
end
fun keyActionCallback mailbox (key, scancode, action, mods) =
if
key = Input.KEY_Z () andalso action <> Input.RELEASE ()
andalso mods = 0x0002
then Mailbox.send (mailbox, UNDO_ACTION)
else ()
fun registerCallbacks (window, inputMailbox) =
let
val mouseMoveCallback = mouseMoveCallback inputMailbox
@@ -33,6 +38,10 @@ struct
val resizeCallback = framebufferSizeCallback inputMailbox
val _ = Input.exportFramebufferSizeCallback resizeCallback
val _ = Input.setFramebufferSizeCallback window
val keyCallback = keyActionCallback inputMailbox
val _ = Input.exportKeyCallback keyCallback
val _ = Input.setKeyCallback window
in
()
end