scaffolding for arrow-movement functionality

This commit is contained in:
2025-09-01 11:23:45 +01:00
parent 53082315ac
commit a10e56935e
4 changed files with 30 additions and 0 deletions

View File

@@ -10,6 +10,11 @@ int KEY_ESC = GLFW_KEY_ESCAPE;
int KEY_ENTER = GLFW_KEY_ENTER; int KEY_ENTER = GLFW_KEY_ENTER;
int KEY_BACKSPACE = GLFW_KEY_BACKSPACE; int KEY_BACKSPACE = GLFW_KEY_BACKSPACE;
int KEY_ARROW_LEFT = GLFW_KEY_LEFT;
int KEY_ARROW_RIGHT = GLFW_KEY_RIGHT;
int KEY_ARROW_UP = GLFW_KEY_UP;
int KEY_ARROW_DOWN = GLFW_KEY_DOWN;
void framebufferSizeCallback(GLFWwindow* window, int width, int height) { void framebufferSizeCallback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
mltonFramebufferSizeCallback(width, height); mltonFramebufferSizeCallback(width, height);

View File

@@ -39,4 +39,17 @@ struct
val (KEY_BACKSPACE, _) = val (KEY_BACKSPACE, _) =
_symbol "KEY_BACKSPACE" public : ( unit -> int ) * ( int -> unit ); _symbol "KEY_BACKSPACE" public : ( unit -> int ) * ( int -> unit );
val KEY_BACKSPACE = KEY_BACKSPACE () val KEY_BACKSPACE = KEY_BACKSPACE ()
val (KEY_ARROW_LEFT, _) =
_symbol "KEY_ARROW_LEFT" public : ( unit -> int ) * ( int -> unit );
val KEY_ARROW_LEFT = KEY_ARROW_LEFT ()
val (KEY_ARROW_UP, _) =
_symbol "KEY_ARROW_UP" public : ( unit -> int ) * ( int -> unit );
val KEY_ARROW_UP = KEY_ARROW_UP ()
val (KEY_ARROW_RIGHT, _) =
_symbol "KEY_ARROW_RIGHT" public : ( unit -> int ) * ( int -> unit );
val KEY_ARROW_RIGHT = KEY_ARROW_RIGHT ()
val (KEY_ARROW_DOWN, _) =
_symbol "KEY_ARROW_DOWN" public : ( unit -> int ) * ( int -> unit );
val KEY_ARROW_DOWN = KEY_ARROW_DOWN ()
end end

View File

@@ -7,4 +7,8 @@ struct
| KEY_BACKSPACE | KEY_BACKSPACE
| RESIZE_EVENT of int * int | RESIZE_EVENT of int * int
| WITH_SEARCH_LIST of int vector | WITH_SEARCH_LIST of int vector
| ARROW_LEFT
| ARROW_UP
| ARROW_RIGHT
| ARROW_DOWN
end end

View File

@@ -29,6 +29,14 @@ struct
Mailbox.send (inputMailbox, InputMsg.KEY_ENTER) Mailbox.send (inputMailbox, InputMsg.KEY_ENTER)
else if key = KEY_BACKSPACE andalso action <> RELEASE andalso mods = 0 then else if key = KEY_BACKSPACE andalso action <> RELEASE andalso mods = 0 then
Mailbox.send (inputMailbox, InputMsg.KEY_BACKSPACE) Mailbox.send (inputMailbox, InputMsg.KEY_BACKSPACE)
else if key = KEY_ARROW_LEFT andalso action <> RELEASE andalso mods = 0 then
Mailbox.send (inputMailbox, InputMsg.ARROW_LEFT)
else if key = KEY_ARROW_RIGHT andalso action <> RELEASE andalso mods = 0 then
Mailbox.send (inputMailbox, InputMsg.ARROW_RIGHT)
else if key = KEY_ARROW_UP andalso action <> RELEASE andalso mods = 0 then
Mailbox.send (inputMailbox, InputMsg.ARROW_UP)
else if key = KEY_ARROW_DOWN andalso action <> RELEASE andalso mods = 0 then
Mailbox.send (inputMailbox, InputMsg.ARROW_DOWN)
else else
() ()
end end